[Zope-dev] Zope2.7.0rc2 AttributeError: 'NoneType' object has noattribute 'setHeader'

Shane Hathaway shane at zope.com
Mon Feb 9 17:02:55 EST 2004


On Mon, 9 Feb 2004, Lennart Regebro wrote:

> From: "Dieter Maurer" <dieter at handshake.de>
> > Maybe, we have a memory corruption.
> > I have seen objects magically becoming "None" in
> > Python versions with memory corruption problems (Python 2.1.1).
> 
> Also, loads of objects can become None when you do a refresh, because of
> some strange bug in the refresh support that has been there since it got
> integrated into the core and which nobody seems to understand.

It's actually a behavior of Python itself.  When Zope's Refresh calls
Python's reload() builtin, reload() twiddles the old functions and methods
in such a way that all old globals are set to None.  If you have the
misfortune of calling an old function or method, it's likely to fail in
the manner Dieter described.  It is not memory corruption.  It is the
intended behavior.

Therefore, reload() only works if you can reliably sever all references to
functions or methods in the old module.  Zapping the ZODB cache
accomplishes most of that, but there are still cases that bite people.

I think the only way to make Refresh work reliably is to create a special 
kind of module that's explicitly refreshable.  The module would obey some 
special rules.  Fortunately, that's just what Zope 3's persistent modules 
will do.  For now, you just have to be aware that Refresh is designed only 
for simple products that do not create or use module-level registries.

Shane



More information about the Zope-Dev mailing list