[mod_python] Using shared memory to do global persistence

VanL vlindberg at verio.net
Fri Jun 27 09:02:51 EST 2003


Jack Diederich wrote:

> In the future setting variables in other module spaces may be
>
>outlawed in python.  Treating modules like classes/objects
>is also strongly discouraged.
>

Hmm. But who said that "shared" had to be a module?  It could just as 
easily be an instantiation of a class that is instantiated when 
mod_python starts.  That might actually make more sense, as someone 
implementing a shared module would only need to override the __getattr__ 
and __setattr__ hooks.

For example, in the mod_python initialization:

if options.has_key('shared-memory'):
    global shared
    shared = sharedmemoryimplementation()

The rest of the code I provided when then work unchanged.  It doesn't 
have to be a module, just a *namespace*.

>mod_python.page_cache # caching dict created per-request
>mod_python.perm_cache # cache valid accross all processes for ever
>

This is a good idea.  +1.

VanL



More information about the Mod_python mailing list