[mod_python] newb question on apache conf

Jorey Bump list at joreybump.com
Sat Feb 26 10:09:14 EST 2005


Graham Dumpleton wrote:

> You would be better off not using PythonInterpPerDirective. Just set the
> interpreter name directly. Ie.,
> 
> <Directory /var/www>
>     <FilesMatch "holygrail|lifeofbrian|meaningoflife">
>         PythonInterpreter "monty"
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>         PythonDebug On
>         PythonPath "['/home/monty/python'] + sys.path"
>     </FilesMatch>
>     <FilesMatch "jabberwocky|timebandits|brazil">
>         PythonInterpreter "gilliam"
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>         PythonDebug On
>         PythonPath "['/home/gilliam/python'] + sys.path"
>     </FilesMatch>
> </Directory>
> 
> This way in a different part of the directory hierarchy one could extend
> the set of files which are handled within a specific interpreter for a
> user.

That's a good point. In either case, you're abstracting the risk of name 
collisions to another level.

For example, in an environment with multiple virtual hosts, you'd need 
to ensure that named interpreters weren't being shared unintentionally. 
So, if you develop in an environment with virtual hosts named 
test.example.com and www.example.com, you'd want to distinguish the 
interpreter in the test environment, somehow:

   PythonInterpreter "test-monty"

Is it possible to pass a variable as the name, or to rename it while 
it's running, to guarantee some measure of uniqueness? I tried renaming 
req.interpreter, but it's a readonly attribute.





More information about the Mod_python mailing list