attempting to contact the author

11 views
Skip to first unread message

primco

unread,
Aug 16, 2006, 4:00:18 PM8/16/06
to isapi_wsgi-dev
Hello Mark,
If you're listening, I'd like to get isapi-wsgi working with pylons and
I'd like to contact you to get some more information.

thanks.
davep

Mark Rees

unread,
Aug 16, 2006, 7:21:22 PM8/16/06
to isapi_w...@googlegroups.com
Yes I am listening :-) How can I help?

Mark

primco

unread,
Aug 16, 2006, 7:31:26 PM8/16/06
to isapi_wsgi-dev
Well, I see that it uses wsgiref in the sample, and I'd like to do a
proof-of-concept with pylons (which is using paste) but I don't know
enough about the differences between wsgiref and pylons.

Mark Rees

unread,
Aug 16, 2006, 8:08:10 PM8/16/06
to isapi_w...@googlegroups.com
I haven't tried with isapi-wsgi with pylons myself but it should work
as I have had simple paste based apps working 6 months ago. I haven't
looked a pylons since they made it a full wsgi stack. The tough bit
will be that you will not able to use paste.deploy for the actual
server setup.

I think you will need to create a isapi wsgi setup script something
like this in your pylons app root directory:

from pylons import wsgiapp

demo_app = wsgiapp.PylonsApp()

import isapi_wsgi
# The entry points for the ISAPI extension.
def __ExtensionFactory__():
return isapi_wsgi.ISAPISimpleHandler(demo = demo_app)

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-pylons-demo",
Description = "ISAPI-WSGI Pylons Demo",
ScriptMaps = sm,
ScriptMapUpdate = "replace"
)
params.VirtualDirs = [vd]
HandleCommandLine(params)

Then run the script

python setup-pylons.py

And you should be able access it by the url:

http://localhost/isapi-wsgi-pylons-demo/

Hopefully this helps.

Another option would be to use fastcgi for IIS and flup. I know this
works well with Pylons under apache and it should work for IIS.

http://www.caraveo.com/fastcgi/

Regards

Mark

On 8/17/06, primco <pri...@gmail.com> wrote:
>

primco

unread,
Aug 17, 2006, 2:14:13 PM8/17/06
to isapi_wsgi-dev
Thanks for this code sample. I'll look into it once i get the samples
working. Turns out i was a little premature -- it seems to install into
IIS but i can't get any sample to display helloworld on any system i've
tried it on. Here's what shows up when I try to run
http://localhost/sapi-wsgi-test/test:
"<html><head><title>Error</title></head><body>The system cannot find
the file specified. </body></html>"

Using
iis5.1
wsgiref library from http://cvs.eby-sarna.com/wsgiref/
python 2.4.3

I can run the plain isapi pywin32 samples like advanced.py
I've tried turning on tracing as in the readme but that doesn't change
anything. Should I be looking for trace output somewhere else?

btw: There seems to be a newer version of wsgiref.
http://cheeseshop.python.org/pypi/wsgiref

thanks

primco

unread,
Aug 17, 2006, 6:22:43 PM8/17/06
to isapi_wsgi-dev
well, on a R2 system running IIS6 i got the isapi-wsgi demo apps going.
Then, I got some help from Pylons and found that I it would help to
start my app using paste since paste created it:

from paste.deploy import loadapp
import os

wsgiapp = loadapp('config:C:\code\iis\development.ini',
relative_to='c:\code\iis')

import isapi_wsgi etc....

(I had to hardcode the paths to my application to get it to install)

Anyhow, now when i run my app on a system that can run the isapi-wsgi
demo apps, i get a page that says "Unspecified Error"

these error pages are really annoying! where are the real errors going?
and how are they being supressed? i'd like to turn that behavior off
during development.

thanks again. seems like i'm getting close.

Mark Rees

unread,
Aug 17, 2006, 8:58:39 PM8/17/06
to isapi_w...@googlegroups.com
Do not believe the the isapi-wsgi adaptor actually generates the
Unspecified error. It more likely an exception is occurring inside IIS
or Pylons. You should be able to catch this using the
win32traceutil.py

To actually see the output as it is produced, start a DOS prompt, and
run the file "win32traceutil.py" (eg, double-click on it from
Explorer, or "python.exe win32traceutil.py") This will print all
output from all other Python processes (that have imported
win32traceutil) until you kill it with Ctrl+Break!)

You should ensure that only one "collector" process is running at a
time. If not, only one of the collector processes will see the output
- although which process gets which bit of output is indeterminate!

Mark

primco

unread,
Aug 18, 2006, 9:14:06 PM8/18/06
to isapi_wsgi-dev
This helps soooo much. I may be going to far into paste/setuptools for
this group but I just though I'd post where I'm stuck now. Thanks to
win32traceutil I now know that I get an import error. I can import
these modules from the python shell but under IIS it throws setuptools
errors.

First error I got was the result of not being able to find an egg that
is in the root of the folder that contains my setup-pylons.py script.
This is the folder I passing in to loadapp. 'c:\code\iis'. Strange. I
made an egg link in my site-packages back to it and then it got past
that import. But then I got another error that it can't find WSGIUtils
(which is already properly installed in site-packages).

File
"c:\python24\lib\site-packages\PasteDeploy-0.9.6-py2.4.egg\paste\deploy\loadwsgi.py",
line 552, in find_egg_entry_point
pkg_resources.require(self.spec)
File
"c:\python24\lib\site-packages\setuptools-0.6c1-py2.4.egg\pkg_resources.py",
line 585, in require
needed = self.resolve(parse_requirements(requirements))
File
"c:\python24\lib\site-packages\setuptools-0.6c1-py2.4.egg\pkg_resources.py",
line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: WSGIUtils==0.7

This happens on 3 different systems.

mark.jo...@gmail.com

unread,
Aug 19, 2006, 3:02:11 AM8/19/06
to isapi_wsgi-dev
Do not access network access to my IIS installation for the next couple
of days so cannot look at the problem in depth. I wonder if it
something to do with how python is seeing sys.path when running inside
IIS. I have had strange sys.path issues with other python services in
the past.. Suggest you create a simple wsgi app to run under isapi_wsgi
and print the sys.path to see what it is.An ugly hack would be to set
sys.path correctly in the python script you install with isapi_wsgi.

primco

unread,
Aug 21, 2006, 7:43:27 PM8/21/06
to isapi_wsgi-dev
I worked around all the errors.

The import errors were the result of having eggs that were in zip
format instead of folders. I manually expanded them into folders and
got around the errors. I have no idea why it doesn't work. I tried
'import zipimport', on a tip that that might be the culprit, in my
script and I am able to import it.

So after that, I was still not getting a response from my app. Say my
app serves up index.html in its root folder. This url does not work:
http://localhost/isapi-wsgi-pylons-demo/index.html

Turns out that this code chunk

demo_app = loadapp('config:C:/code/iis/development.ini',
relative_to='C:/code/iis/')


def __ExtensionFactory__():
return isapi_wsgi.ISAPISimpleHandler(demo = demo_app)

sends a dictionary of apps that looks like
{'demo': <paste.registry.RegistryManager object at 0x01F14F70>}
to the ISAPISimpleHandler and this code chunk

if url[-1] == "/":
url = url[:-1]
sn = fixScriptname(ecb.GetServerVariable('SCRIPT_NAME'))
wsgi_appname = sn.split("/")[-1]
application = self.apps.get(wsgi_appname, None)

which results in a base URL for my app of
http://localhost/isapi-wsgi-pylons-demo/demo/index.html

so all my pages start here. I'd like to reduce this to just one level
deep:

http://localhost/isapi-wsgi-pylons-demo/index.html

So what would you recommend to shorten this and have my app be the same
as the virtual directory? I see how it allows multiple WSGI apps at the
base but I have that handled upstream with pylons.

Other things of note:
You must stop and restart the IIS service in order to have code changes
reflected on a reload of the page. (stopping and starting the website
will not do it)

Mark Rees

unread,
Aug 21, 2006, 7:56:42 PM8/21/06
to isapi_w...@googlegroups.com
Great effort to get things going. The reason isapi_wsgi used the app
name in the URL was to allow multiple apps in the same virtual directory
but if you can do this dispatch in pylons I do not see an issue with
modifying the way the is called in the wsgi handler. It would be nice if
we can come up with away so it works both ways.

Mark

primco

unread,
Aug 21, 2006, 8:46:31 PM8/21/06
to isapi_wsgi-dev
I should clarify what I wrote. I was not able to get zip format eggs to
import under IIS. this is a serious problem that can be hacked around
for now but it needs to be resolved.

I have tested it and I now have integrated IIS auth working for my
pylons apps. This was the actual goal.

use integrated authentication on the web virtual dir and turn off anon.
Then hit the page via IE, you'll get eviron variables like this:

'HTTP_AUTHORIZATION': 'Negotiate TlRMTVNTUAA.......'
and later the user id that authenticated is specified:
'REMOTE_USER': 'GTEST\\Administrator'

logging in via firefox you get

'HTTP_AUTHORIZATION': 'NTLM TlRMTVNTUAADAA.......'
'REMOTE_USER': 'GTEST\\Administrator'

primco

unread,
Aug 25, 2006, 6:56:48 PM8/25/06
to isapi_wsgi-dev
I've created a Pylons wiki page with my findings and a tutorial on
setting it up.
I hope the little nagging issues are cleaned up soon.

http://pylonshq.com/project/pylonshq/wiki/ServePylonsWithIIS

Reply all
Reply to author
Forward
0 new messages