Django 1.1 / IIS6 / win2003

35 views
Skip to first unread message

Thomas

unread,
Sep 11, 2009, 3:13:34 PM9/11/09
to PyISAPIe
Hello,

I am trying to setup a Django application on IIS6.

I am trying to use the wsgi approach.
I configured IIS according to the documentation. The Info.py run fine.

I modified the Isapi.py in c:\python26\lib\site-packages\Http :

<--- Start
import sys

sys.path.append(r'C:\Inetpub\mydjango')
#
# Django rev 7002
#
# Due to the nature of this particular script, all the urls in
# Django must start with /app/django/, or whatever you specify
# below.
#
from django.core.handlers.wsgi import WSGIHandler as DjangoHandler
os.environ["DJANGO_SETTINGS_MODULE"] = "mydjango.settings"
---> End

When I tried to load the module manually from the shell I get :

<---Start
>>> import Http
>>> http
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'http' is not defined
>>> Http
<module 'Http' from 'c:\python26\lib\site-packages\Http\__init__.pyc'>
>>> import PyISAPIe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyISAPIe
>>> import Http.Isapi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python26\lib\site-packages\Http\Isapi.py", line 27, in
<module>
from Http.WSGI import RunWSGI
File "c:\python26\lib\site-packages\Http\WSGI.py", line 18, in
<module>
from PyISAPIe import Read, Write, Env, Header
ImportError: No module named PyISAPIe
--->End

Any idea on what is going wrong ?

TIA.

Thomas

unread,
Sep 11, 2009, 3:14:39 PM9/11/09
to PyISAPIe
BTW, I tested with 1.1 RC4

Phillip Sitbon

unread,
Sep 11, 2009, 4:18:45 PM9/11/09
to pyis...@googlegroups.com
Hi Thomas-

Due to how Python 2.5+ treats binary modules, PyISAPIe only becomes a
valid module when its DLL is loaded by IIS (IIS will not load .pyd
files). There are ways around this, but it isn't that important to
have- you can't write to any client from the command line, nor are any
of the process-related parameters going to be the same (e.g. it isn't
helpful for most path-related debugging).

I had started making alternative behavior in the Http package
depending on whether the binary module was available or not, but it's
not done yet for the WSGI module.

If you need to debug your Django code, you might want to just use your
project's manage.py (and the Python web server) and then test it from
IIS after you see it producing what you want. You can also run both at
the same time of course.

- Phillip

Thomas

unread,
Sep 11, 2009, 6:54:00 PM9/11/09
to PyISAPIe
Hello Phillip,

First thank you for your help.
I was trying to debug because I can't get my project starting in IIS.

I get the "python manage runserver" working.
I get the Info.py to work, but maybe I am missing a step.

I kept the default behavior with /app/django/ as in the example. I
also pointed the os.environ["DJANGO_SETTINGS_MODULE"] to my project
setting file.

The modification I have done in Isapi.py are :

import sys
sys.path.append(r'C:\Inetpub\')
sys.path.append(r'C:\Inetpub\mydjango')

from django.core.handlers.wsgi import WSGIHandler as DjangoHandler
os.environ["DJANGO_SETTINGS_MODULE"] = "mydjango.settings"

IIS keep sending me back a 404.
What is the correct way to access the application :
http://127.0.0.1 or http://127.0.0.1/app/django/mydjango ?

I am pretty sure that the problem is my lack of understanding of wsgi.
I am missing the glue between django and pyisapie as both work
separately.

My app is a pretty simple app that return an index page for all urls.

Anyway if you have any hints let me know, I'll continue my
investigation.

PS : I'll be happy to contribute an up-to-date HOWTO when I succeed.
Where is the best location ?

Thomas

unread,
Sep 12, 2009, 3:15:29 AM9/12/09
to PyISAPIe
I was modifying the Isapi.py in in the python site-packages directory
and not the one in C:\PyISAPIe\Http\Isapi.py.

That was not clear in the documentation. I'll add a full procedure as
a group page tomorrow !

Reply all
Reply to author
Forward
0 new messages