[mod_python] pythonpath

Jorey Bump list at joreybump.com
Mon Jan 31 13:53:37 EST 2005

Lionel Roubeyrie wrote:
> Le Lundi 31 Janvier 2005 16:42, Jorey Bump a écrit :
>>Assuming cartair.py is in /topdir/webdir, it should be imported
>>properly, because the directory in which mod_python is defined is
>>prepended to the path (unless PythonPath is set).
> I use index.py in /topdir/webdir (it's a framed page in which the others pages 
> are also in /topdir/webdir. I can put out the .py because I don't really need 
> it, but I don't find how to mix .html and .py files together (and I don't 
> want to use PSP pages because I need to call others modules). The others .py 
> pages use the publisher with a index(req) method, like menu.py 

Because you use AddHandler, you should be able to mix .html and .py 
files. But with Multiviews on, you must take pains to use unique names 
for your files (after removing the extension), or the results will be 
unpredictable (you can't have multiple files named index.html, index.py, 
index.py~, index.cgi, index.jpg, index.bak, etc.). Be sure to remove any 
extraneous backup files, which sometimes cause problems with MultiViews.

> which have to 
> call cartair.py located in /topdir (and not /topdir/webdir!), and this is the 
> problem. One time they can call cartair.py, another time not.

Sorry, I missed the location in your PythonPath directive. If I may ask, 
why must cartair.py be in /topdir? There are any number of reasons why 
this may be a bad idea, but I'm not familiar enough with your setup to 
comment on the restriction. In any case, it must be in your path,  so 
use the PythonPath directive. Keep in mind that this will remove 
/topdir/webdir from being automatically added to your path, so if you 
are importing modules from that directory, it will also need to be added 
to PythonPath.

More information about the Mod_python mailing list