[mod_python] ZODB and mod_python.

Sean Reifschneider jafo at tummy.com
Mon Nov 29 17:45:30 EST 2004


On Mon, Nov 29, 2004 at 02:30:29PM -0600, Jon-Pierre Gentil wrote:
>Has anyone used ZODB with mod_python?

No, but JOTWeb (http://jotweb.tummy.com/) uses the Zope 3 TAL engine.  The
code was kind of hairy to understand, but I did eventually get it working
and it's been quite happy since.  Note that they're trying to split Zope 3
up into the component parts so that you can extract just the parts you need
and not require the whole Zope install.  I've never been able to get that
to work though.  I've reported the problems I had to Fred Drake, so it may
be fixed now.

The software for getting just the parts is:

   http://www.zope.org/Members/fdrake/zpkgtools/

>I'm curious about something:  How did you keep it from loading and
>unloading the whole database with each page request?  a global object
>that stays instantiated?

For me, that's not an issue.  I use PostgreSQL as my data store in most
cases, and am not really that concerned in most cases about startup
overhead, so I just make a connection for every request.  It's almost
certainly lighter than making a new ZODB connection every time though.

Putting the connection in a persistent object should do the job.  Of
course, if you have multiple httpd instances running, they will each have
to make a connection, so it may take quite a few page reloads on your test
system before you notice it using the cached object.  On my test system I
make each httpd only handle one request, so I would never notice it anyway.

Sean
-- 
 There are things that are so serious that you can only joke about them.
                 -- Heisenberg
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin


More information about the Mod_python mailing list