Hopefully this will be helpful to someone else. Turned out
reinstalling PyWin32 helped me get the demo to work -- not sure what
the deal is with ActivePython's supposedly included version.
While I did get the demos to work, I have a relatively complex Django/
Pinax web app, and just could not figure out how to get it working
with isapi-wsgi. Not sure the best way to debug further and couldn't
spend more than a half day fiddling around. I ended up going with a
dual IIS/Apache+mod_wsgi setup on the machine. I thought I'd post my
isapi-wsgi setup file below for any use others may get out of it.
It's nearly identical to what I use on a working Apache deployment,
just without the bottom isapi-wsgi-specific section. When run through
an IIS site per above (where demos worked fine), this setup gives me
some trace debugging info, but my browser just hangs indefinitely on
the first page load. Again, the same setup without the isapi-wsgi
stuff at the end works great on Apache. Might be something more
complicated than the setup file, I realize.
# isapi-wsgi.py
# run python isapi-wsgi.py --server=Name_Of_IIS_Site
import os, sys, site
from os.path import abspath, dirname, join
if hasattr(sys, "isapidllhandle"):
import win32traceutil
BELOW_PROJECT_ROOT = abspath(join(dirname(__file__), "..\\..\\"))
PROJECT_ROOT = abspath(join(dirname(__file__), "..\\"))
PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1]
# For virtualenv
EXTRADIRS = ['\\Python26\\envs\\django12\\lib\\site-packages']
sys.path.insert(0, join(PROJECT_ROOT, "apps"))
sys.path.insert(0, PROJECT_ROOT)
sys.path.insert(0, BELOW_PROJECT_ROOT)
# Remember original sys.path
prev_sys_path = list(sys.path)
# Add each new site-packages directory
for directory in EXTRADIRS:
site.addsitedir(directory)
# Reorder sys.path so new directories are at the front
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
sys.stdout = sys.stderr
os.environ["DJANGO_SETTINGS_MODULE"] = PROJECT_NAME + ".settings"
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
# ISAPI_WSGI - specific
import isapi_wsgi
def __ExtensionFactory__():
return isapi_wsgi.ISAPISimpleHandler(application)
if __name__=='__main__':
from isapi.install import *
params = ISAPIParameters()
sm = [
ScriptMapParams(Extension="*", Flags=0)
]
vd = VirtualDirParameters(Name="/",
Description = "ISAPI-WSGI ConSource",
ScriptMaps = sm,
ScriptMapUpdate = "replace"
)
params.VirtualDirs = [vd]
HandleCommandLine(params)