[mod_python] psp_site example doesn't work

grahamd at dscpl.com.au grahamd at dscpl.com.au
Mon Jan 24 20:11:51 EST 2005


Jorey Bump wrote ..
> But if you start the interpreter in a subdirectory, such as /var/www/py,
> it would be prepended to sys.path:
> 
> <Directory /var/www/py>
>    AddHandler python-program .py
>    PythonHandler mod_python.publisher
>    PythonDebug On
> </Directory>
> 
> Finally, remember that declaring a path explicitly with PythonPath 
> overrides this behaviour.

FWIW, I recommend with Vampire that people set:

  PythonPath 'sys.path'

This has the effect of avoiding sys.path being extended with paths
in your document tree.

The idea then is one supplies an explicit directory to look in for
your application modules to an import function such as the
apache.import_module() function or that supplied with Vampire.
For standard Python modules installed with Python, one continues
to use the "import" statement.

This avoids all the sys.path unpredictability as it nevers gets
changed and is only consulted for standard Python modules.

Graham


More information about the Mod_python mailing list