[mod_python] cgihandler, w2k

Roger Baklund roger.baklund at mobiliant.com
Wed May 15 17:49:38 EST 2002


we have installed mod_python on a w2k server, and the mptest.py "Hello
world" is working.

However, when running a cgi application through the cgihandler, we have some

First, we thought it was working, but it was not, as we saw many python
processes coming and going in the task manager, as if it was running like a
normal cgi.

We reinstalled, and we patched some lines in apache.py, function
setup_cgi(), according to notes found on this mailinglist ("old_env =
os.environ.copy()" and "return old_env, si, so").

This time the cgihandler was running, and we found some problems in the cgi
that we fixed ("if __name__ == '__main__':" and some redirects that went
wrong because of missing status header.)

Then we got some strange errors... it started to complain about modules not
existing, when it was trying to delete from sys.modules. This is in the
beginning of the cgihandler.py handler() function.

We had to move the "_lock.acquire()" to before the sys.modules loop to get
rid of the error messages.

We tried to remove the sys.modules loop (as indicated in a comment in the
source), but we could not make that work. We always get Internal Server
Error when we try to run without this module reload mechanism. See log
entries below.

The application is frames based. When the user log in, a frameset is
returned, and new requests are made for a stylesheet, a couple of external
javascripts, and a couple of cgi-based html pages/frames.

More information about the Mod_python mailing list