[mod_python] Different scripts with same names and sys.path confusion

Jure Vrscaj jure at dijaski.net
Fri Jan 20 12:52:07 EST 2006


I'm working on a web-based gui for some application in mod_python, using 
publisher as a request handler. The project was going on ok, until I 
made a copy of the application, so that one copy could be used for 
testing/development and the other for real usage. But, as soon as two 
copies existed on the same server, one being requested after another, I 
noticed some strange effects:

At first, every now and then, I got a "404 Not Found" error when 
requesting one of the two copies. I traced the error which was raised in 
apache.py, the reason being that the module's directory I was trying to 
access wasn't in the path(which is calculated from request url). I 
commented out the check, and tried again. Now the error was gone, but 
another issue arised: when requesting for example the development page, 
which has the title set to "Test", instead of seeing the correct title, 
I got (seemingly randomly) titles from both the test site and the real one.

I figured that wrong modules are being used/imported and made the script 
output sys.path. The path contained both: root folder of the testing 
site and next to it root folder of the real site, which was probably the 
reason why the titles were unstable. I tried setting PythonPath, with no 

My system specs are:
- redhat linux
- httpd-2.0.46-54.ent (apache2.0)
- python-2.2.3-6.1
- mod_python-3.0.3-5.ent
- handler: mod_python.publisher

I would use Vampire, but couldn't get it to work on python2.2.

Any suggestions on how to overcome this problem really appreciated, I 
don't mind if each module is reloaded for every request, as long as it's 
the right module. (the application is using classic python import 
command for module importing)


More information about the Mod_python mailing list