durusmail: quixote-users: Serving quixote through iis (while fixing a Quixote-WSGI bug)
Serving quixote through iis
2005-10-06
Serving quixote through iis (while fixing a Quixote-WSGI bug)
Re: R: [Quixote-users] Serving quixote through iis (while fixing a Quixote-WSGI bug)
2005-10-06
2005-10-06
2005-10-06
2005-10-06
2005-10-07
Re: R: [Quixote-users] Serving quixote through iis
2005-10-07
Re: R: [Quixote-users] Serving quixote through iis
2005-10-07
Serving quixote through iis (while fixing a Quixote-WSGI bug)
Daniele Varrazzo
2005-10-06
> -> probably i will be asked to deploy a Quixote application on a
> machine already web-serving through IIS. The application mantains
> its own state and pools db connections, so CGI is not a choice.
> Up to now i only found tips about using Python as a cgi language
> or into asp pages.

> google "iis wsgi"  (there are several different relevant hints) and then
> use the QWIP class in
>
>       http://cafepy.com/quixote_extras/rex/wsgi_server.py
>
> to run Quixote under WSGI.

Thank you very much: with some effort i got the quixote demo work into IIS
through wsgi. I had some problem because:

qwip_test (http://isapi-wsgi.python-hosting.com/file/trunk/examples/qwip_test.py
- the mantainer Mark Rees is in cc) is a bit outdated: in the module docstring
it refers to Quixote 1.2. To make it work with
http://cafepy.com/quixote_extras/rex/wsgi_server.py and Quixote 2.1, the
following patch is required:

------------8<--------------

--- qwip_test.py.bak    2005-10-06 19:32:04.046875000 +0200
+++ qwip_test.py        2005-10-06 17:27:39.421875000 +0200
@@ -18,11 +18,15 @@
 #

 import isapi_wsgi
-import qwip
+from wsgi_server import QWIP
+from quixote.util import import_object
+
+factory = "quixote.demo.create_publisher"

 # The entry points for the ISAPI extension.
 def __ExtensionFactory__():
-    return isapi_wsgi.ISAPISimpleHandler(demo = qwip.QWIP('quixote.demo'))
+    publisher = import_object(factory)()
+    return isapi_wsgi.ISAPISimpleHandler(demo = QWIP(publisher))

 if __name__=='__main__':
     # If run from the command-line, install ourselves.

------------8<--------------

Furthermore a bug in Quixote prevents it to run with the wsgiref package
(http://svn.eby-sarna.com/wsgiref/): HTTPResponse.generate_headers() returns the
content length as an int instead of a string, and this triggers an assert in
BaseHandler.start_response() (and the attitude of the ms world to carefully hide
the stderr made me lose an afternoon).

The issue is not related to IIS, but to WSGI. The following patch applies to
Quixote 2.1, but looking at 2.2 source i think there is the same issue:

------------8<--------------

--- http_response.py.bak        2005-08-09 00:59:12.000000000 +0200
+++ http_response.py    2005-10-06 19:46:54.762688000 +0200
@@ -409,7 +409,7 @@
         if "content-length" not in self.headers:
             length = self.get_content_length()
             if length is not None:
-                headers.append(('Content-Length', length))
+                headers.append(('Content-Length', str(length)))

         return headers

------------8<--------------

Thank you very much for the help. I can always count on you.

Daniele

P.S. to Thomas: i believe SCGI doesn't work under win32 out of the box:
http://mail.mems-exchange.org/pipermail/quixote-users/2003-July/001797.html.

reply