IIS, pyisapie, and DJANGO_SETTINGS_MODULE

274 views
Skip to first unread message

rcs_comp

unread,
May 9, 2008, 4:24:22 AM5/9/08
to Django developers
So I have setup Django on IIS using PyISAPIe and am happy with the
performance so far. On my dev box running IIS 5.1, I am getting ~170
requests per second processed for the simple poll application.

Django is running as a WSGI application. I have reconfigured the
PyISAPIe files to look for a default configuration file in a virtual
directory. Therefore, each virtual directory and/or website can have
its own python configuration file. My intent was to be able to
specify a different Django project for multiple different virtual
directories/websites. The configuration file per virtual directory
looks like this:

### START CODE

import os, sys
sys.path.append('D:/system_data/development/python/django')

from django.core.handlers.wsgi import WSGIHandler as DjangoHandler
from Http.WSGI import RunWSGI
import inspect, string

#
# The main request handler.
#
def Request():
os.environ['DJANGO_SETTINGS_MODULE'] = 'dgtutorial2.settings'
return RunWSGI(DjangoHandler())

### END CODE

The problem, which is documented on both the Django Wiki and in the
PyISAPIe documentation is that even though DJANGO_SETTINGS_MODULE is
being reset each time a page is being requested, it doesn't seem to
affect how Django is running.

I realize this probably has something to do with the fact that the
Django settings are being stored at the process level, so even though
the environment variable is being reset each time a request is made,
Django isn't actually reloading the settings.

Can someone help me by giving me a high-level overview of how Django
is working and how/why the settings are being stored at the process
level? What would have to happen to get Django to re-process the
settings file each time a URL was requested?

In the end, my goal is to get a decently performing solution for
multiple installations of Django on an IIS server. I am happy to put
some time and effort into working on a solution for this if someone
can help point me in the right direction.

Thanks.
Reply all
Reply to author
Forward
0 new messages