Jorey Bump
list at joreybump.com
Mon Jan 24 19:39:06 EST 2005
Jorey Bump wrote: > The main effect is that the DocumentRoot might get prepended to sys.path > instead of the directory containing the published module. But a single > interpreter must have a single working directory, so I consider this an > elegant solution. > > If you modify the path with the PythonPath directive, this will no > longer be the case. The DocumentRoot is not prepended to the path and > you will be limited to the directories explicitly listed in PythonPath. > This can lead to surprising behaviour if you created some modules and > packages in the DocumentRoot, because they will no longer work properly. I should stress here that I used DocumentRoot as an example, and it is in no way the default path that gets prepended to sys.path. The Directory in which the interpreter is defined is the path that gets prepended to sys.path. So, if your DocumentRoot is /var/www, it would get prepended to sys.path in the following configuration: <Directory /var/www> AddHandler python-program .py PythonHandler mod_python.publisher PythonDebug On </Directory> 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.
|