[mod_python] newb question on apache conf

Graham Dumpleton grahamd at dscpl.com.au
Sat Feb 26 03:29:20 EST 2005


On 26/02/2005, at 5:01 PM, Jorey Bump wrote:
> On a practical note, this approach shows promise for "registering" 
> your  published modules. For example, let's assume you have some 
> modules named holygrail.py, lifeofbrian.py and meaningoflife.py. Your 
> config could include this:
>
>  <FilesMatch "holygrail|lifeofbrian|meaningoflife">
>
> The names are sophisticated enough to easily avoid accidental 
> collisions with other file names/types, and you can place the modules 
> anywhere within the specified directory, to any depth.
>
> But the real fun begins when you use multiple directives to register 
> modules to specific subinterpreters (to support multiple developers, 
> for example):
>
> <Directory /var/www>
>     PythonInterpPerDirective On
>     <FilesMatch "holygrail|lifeofbrian|meaningoflife">
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>         PythonDebug On
>         PythonPath "['/home/monty/python'] + sys.path"
>     </FilesMatch>
>     <FilesMatch "jabberwocky|timebandits|brazil">
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>         PythonDebug On
>         PythonPath "['/home/gilliam/python'] + sys.path"
>     </FilesMatch>
> </Directory>
>
> A configuration like this allows multiple developers to work somewhat 
> independently, yet reduces the risk of namespace collisions when 
> importing custom modules. Because these directives can be included in 
> a .htaccess file instead of a <Directory> container, coordination 
> among developers can be accomplished fairly easily.

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.




More information about the Mod_python mailing list