[mod_python] Use of global for application data?

Sean Gillies sgillies at frii.com
Wed Sep 24 14:38:53 EST 2003


On Wednesday, September 24, 2003, at 12:31  PM, fumanchu wrote:

>> I've seen examples of how to create persistent database connections
> with
>> mod_python, but not enough examples of other application data.
>> In my case the application data are large objects including page
> templates.
>> Exists a better way than binding values to names in the globals
> namespace?
>
> "THE globals namespace" sounds misleading to me, unless you're talking
> about the __main__ module. Each module has its own global namespace.
>
>> Maybe I just have a hang-up about globals that I need to overcome.
>
> That would depend on what you mean by "a better way". What limitations
> of module.attributes are you seeing? I'd be interested to hear more
> about your design, including your goals for the page templates--are you
> trying to cache them in RAM throughout the life of the application?
>
>
> Robert Brewer
> fumanchu at aminus.net
>

Robert, thanks for the reply.  I went back and re-read the relevant
sections of the Python Reference Manual.  I had misunderstood that
the persistent db connection example in the FAQ was referring to a
name in the __main__ module.

I am using Zope page templates as module attributes and when methods of
my module are called (using the publisher), merging them with data
from several contexts.  I caught and fixed a bug in my code which
was causing numerous (re)loads of the module, and am now having no
problems.

Sean

--
Sean Gillies
sgillies at frii dot com
http://www.frii.com/~sgillies



More information about the Mod_python mailing list