[mod_python] mod_python 3.3 importer with "import" statement

Ben Hoyt ben at micropledge.com
Fri Jun 1 03:50:03 EDT 2007

> By default VirtualHosts use distinct Python interpreter instances.

Thanks for that, Graham. That stuff about Python interpreter instances was
really helpful, and started us hunting down the right track. Anyway, the
problems we were having were caused by:

1) Moving/renaming our root code directory without deleting the *.pyc files.
I think this was adding to the confusion because we were seeing some path
strings from the .pyc files in the error messages.

2) Using mod_python 3.3 on our development servers and something older on
our live one. I think this was confusing us with regard to the import
problem and PythonPath.

3) Relying on relative paths in a few places in our actually (actually in
web.py's template handling, which we're using). We used os.chdir() to set
the current working directory, but of course (we realise now) that the cwd
is process-dependent rather than Python-interpreter dependent. So depending
on which process Apache picked, it'd use the other virtual host's template
directory and confuse everyone. I think I'll tell the web.py people that
depending on relative paths is pretty much a bug (at least with mod_python
-- maybe that's why they haven't seen the bug).

Anyone else using mod_python with web.py, just out of curiosity?

Anyway, it's fixed, and I've got my head around PythonInterpreter and
PythonPath and various other things now. Cheers!

Overriding import is more complicated than just replacing __import__. ;-)

I suspected that was the case. Looks like you've been there and done that.


Ben Hoyt, +64 21 331 841
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070601/31e1012e/attachment.html

More information about the Mod_python mailing list