Monday, February 07, 2005

ISAPI-WSGI - Runs a Quixote application using QWIP

Titus Brown asked me to test if his simple Quixote-WSGI adapter (QWIP) would work with ISAPI-WSGI. The first launch worked, but every other launch failed until IIS was restarted. Traced it to the write method in ISAPISimpleHandler where I was using "print >> self.ecb, data" and this was raising a 10053 error 'An established connection was aborted by the software in your host machine.' Changing it to "self.ecb.WriteData(data)" fixed the problem. Why? will investigate later. Change checked-in as revision 6.

So running quixote.demo with QWIP using ISAPI=WSGI now works. I think this proves that WSGI is a very important standard for Python and the web.

Below is the code to do it:

import isapi_wsgi

import qwip

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

if __name__=='__main__':
# If run from the command-line, install ourselves.
from isapi.install import *
params = ISAPIParameters()
# Setup the virtual directories - this is a list of directories our
# extension uses - in this case only 1.
# Each extension has a "script map" - this is the mapping of ISAPI
# extensions.
sm = [
ScriptMapParams(Extension="*", Flags=0)
]
vd = VirtualDirParameters(Name="isapi-wsgi-qwip-test",
Description = "ISAPI-WSGI QWIP Test",
ScriptMaps = sm,
ScriptMapUpdate = "replace"
)
params.VirtualDirs = [vd]
HandleCommandLine(params)

No comments: