[mod_python] Persist database conn, or pers. variables - where I put them ?

Richard Lewis richardlewis at fastmail.co.uk
Wed Sep 27 10:04:56 EDT 2006


On Wednesday 27 September 2006 14:55, Sean Davis wrote:
> On Wednesday 27 September 2006 09:16, Fredrik Sandin wrote:
> > I asked the same question some time ago:
> > http://modpython.org/pipermail/mod_python/2006-August/021924.html
> > Graham Dumpleton suggested to use XML-RPC.
> >
> > As far as I have understood mod_python, or actually Apache, was
> > not designed to allow for object persistency.
>
> Is this actually true (at least the Apache part)?  Under mod_perl (I'm a
> mod_python total newbie), object persistence can be accomplished in several
> ways including global variables that remain in shared memory (but this is
> only within a single child), a database, in an in-memory or on-disk cache,
> or in a session (just an interface to a cache or database).  Depends on
> your definition, but Apache, it seems to me, is absolutely suited to allow
> object persistence.
>
Persistance is all right: you can use global variables as you suggested.

The problem comes at tidying up time. Apache provides no method of performing 
operations when the server shuts down. This is especially relevant with 
things like open database connections and is probably why the original poster 
was talking about XML-RPC. A workable solution is to open your database 
connections in a separate process to Apache/mod_python and connect via a 
local socket or with something like XML-RPC or with 
http://sourceforge.net/projects/sqlrelay

Cheers,
Richard
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
Sonic Arts Research Archive
http://www.sara.uea.ac.uk/
JID: ironchicken at jabber.earth.li
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


More information about the Mod_python mailing list