[mod_python] newb question on apache conf

Jorey Bump list at joreybump.com
Sat Feb 26 01:01:32 EST 2005


Jorey Bump wrote:

> And possibly in the category of stupid apache/mod_python tricks:
> 
> <Directory /var/www>
>     <FilesMatch "foo">
>         SetHandler python-program
>         PythonHandler mod_python.publisher
>         PythonDebug On
>     </FilesMatch>
> </Directory>

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.

Is there any way to reliably kill a child process associated with a 
specific subinterpreter, so a developer could force his own 
subinterpreter to restart without restarting apache?



More information about the Mod_python mailing list