[ZODB-Dev] Re: [Zope3-dev] Persistent module notes and proposal

Jeremy Hylton jeremy at zope.com
Mon Jan 5 12:34:48 EST 2004


On Mon, 2004-01-05 at 11:38, Tres Seaver wrote:
> > This certainly sounds reasonable. We need to make sure this is
> > enforced at some level though, preferrably through software (disallowing
> > mutating globals in the module somehow) or at least through very strong
> > documentation (such as a comment at the top of the module that appears
> > by default or an electrostatic charge administered to the chair of the
> > respective programmmer). Otherwise I sense an endless barrage of newbie
> > FAQs re this in our future...
> 
> Surely we can replace the __dict__ of the PM with something "frozen", 
> thawing it only when recompiling the source.  I wouldn't want anything 
> "advisory" at all, here;  that would be just a bug magnet (FAQs too).

Not easily.  Python will only accept a real dict as a function's
globals.  So all the functions in the module would have access to the
real dict.  

Perhaps code with global statements should be disallowed.  This wouldn't
prevent all modifications, but would prevent some modifications. 
Persistent functions are already on the lookout for global assignments,
because they mark the module as modified (_p_changed = True).

It would be nice to implement this restriction as part of Zope's support
for persistent code so that ZODB users could still have mutable state in
a module if they really wanted it.

Jeremy





More information about the ZODB-Dev mailing list