Trying to get a simple demo working - browser just hangs

12 views
Skip to first unread message

Dave Marble

unread,
Jul 19, 2010, 5:13:31 PM7/19/10
to isapi_wsgi-dev
Hi there,

I was excited to find isapi-wsgi and am trying to get a demo to run
without success.

Setup:
Windows 2003 Server (32-bit)
IIS 6
Activestate Python 2.6.5 (x86 32-bit build, which comes with PyWin32)

I installed the win32 binary distribution of isapi-wsgi 0.4.2. I
created a new site in IIS called "Test" listening on all unassigned IP
addresses (the default setting) and set the home directory to c:
\inetpub\wwwroot\test. I put a quick index.htm there to test it and
it serves fine. I then put demo_serve_from_root.py (http://
code.google.com/p/isapi-wsgi/source/browse/trunk/examples/
demo_serve_from_root.py) in that directory, renamed it to test.py, and
ran "python test.py --server=Test". The command completed
successfully, _test.dll was generated in the directory and shows up as
an allowed extension, and also as a wildcard application mapping under
the new website properties -> Home Directory -> Configuration. I did
an iisreset for good measure, opened a local browser, browsed to
http://localhost and it just hangs indefinitely.

To try a previous poster's suggestion, I ran "python test.py remove",
iisreset, deleted _test.py, then tried "python test.py --
server=87257621" [this is the Identifier for my new website "Test"
which can be found if you click on "Web Sites" at the root of all your
sites]. Same result as above.

Any ideas? Would love to get this running so I can serve some django
apps for work on our co-located IIS box.

Much thanks for any advice!

Mark Hammond

unread,
Jul 20, 2010, 1:21:10 AM7/20/10
to isapi_w...@googlegroups.com, Dave Marble
On 20/07/2010 7:13 AM, Dave Marble wrote:
> Hi there,
>
> I was excited to find isapi-wsgi and am trying to get a demo to run
> without success.
>
> Setup:
> Windows 2003 Server (32-bit)
> IIS 6
> Activestate Python 2.6.5 (x86 32-bit build, which comes with PyWin32)

Off the top of my head, the only thing I can think of is the "normal"
dramas associated with Python 2.6 and assemblies. You might like to try
either using python 2.5, or try finding and installing the MS
redistributables for Visual Studio 2008.

Mark

Dave Marble

unread,
Jul 20, 2010, 4:24:28 AM7/20/10
to isapi_wsgi-dev
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)
Reply all
Reply to author
Forward
0 new messages