[mod_python] Hi, database connection queston

Cary O'Brien cobrien at Radix.Net
Sun May 28 10:29:51 EST 2000


Hi,

Glad to hear about mod_python, it is almost exactly what I am looking for. 
I've used mod_perl/embperl and mod_dtcl, but I really wanted to try using
python.

I'm going to try to fire it up over the long weekend.

I've got a couple of questions (of course).

1) How are people handling persistant database connections?  Ideally (for me)
   there would be a single db connection for each apache process.  That 
   minimizes connection setup time (non-trivial for PostgreSQL at least),
   lets me control the number of database connections (apache max-servers), 
   and lets me control their lifetimes (i.e. serve 10,000 requests then exit),
   and restarts them if they die.  Nice eh?

   My question is how do I setup a shared database connection used by each
   handler?  It seems from the documentation that each request gets its own
   subinterpreter.  I'd like them all to be handled by the same sub-interpreter.
   Or, in reality, just share the same db connection.

   The python doc for Py_NewInterpreter() says

     the new interpreter has separate, independent versions of all imported modules, 

   So what happens to class variables.  Can I connect to the database there?

2) Re Zope.  There seems to be a ZPublisher interface.  Does this mean I can
   run 30 apache processes against the same Zope database?  How fine/course is
   the locking on the zope database?  I asked this on the zope list a while
   back and didn't get a good answer.

3) Does anyone have the bits to embed python calls in an html document a-la 
   embperl/php/mod_dtcl? I know mixing logic with presentation is 
   in general a bad idea, but having embedded code in documents is a fast
   way to get things up and running.
   
-- cary

Cary O'Brien
cobrien at radix.net



 







More information about the Mod_python mailing list