[mod_python] Child process init handler

Daniel West dwmp at opti.cgi.net
Tue Jan 27 11:53:53 EST 2004


Mike,

Unfortunately mod_python is a little lacking when it comes to 
initialization capabilities.  If you've missed something in the docs then 
I've missed it too.  As it turns out, it's not such a bad thing to do 
initialization on the first request.  Subsequent requests run in the same 
post-initialized environment (interpreter).  For instance, make a db module 
for your database interface.  On the first request, make a database 
connection and store the connection object in the database module.  On the 
next request, your database connection will still be there, alive and ready 
to use.

I think it would be very nice, convenient and helpful to new developers to 
have PythonImport work under virtual domains and to provide a method for 
accessing the PythonOptions of the domain under which PythonImport was 
called.  I know I spent several frustrating evenings, while taking up 
mod_python, trying to figure out how to make initialization work elegantly.

-Dan



At 11:55 AM 1/27/2004 -0500, you wrote:
>What I want to do:
>
>         Run some initialization code when Apache spawns the child
>process.  I do not want to call this handler for every request, but I do
>want to have access to the configuration, specifically PythonOptions
>
>In looking though the docs, I'm not sure PythonInitHandler works this
>way, and PythonImport may not be able to access the PythonOption
>directives.  Is there something I'm overlooking?
>
>Mike
>
>_______________________________________________
>Mod_python mailing list
>Mod_python at modpython.org
>http://mailman.modpython.org/mailman/listinfo/mod_python




More information about the Mod_python mailing list