On 1/30/06, Dieter Maurer <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote at 2006-1-30 18:54 +0000:
> >I've noticed another strange behaviour with the Acquisition module in
> >Zope 2.9 that might give us some clues as to why refreshing doesn't
> >work.
> >
> >Imagine some code that looks like this::
> >
> >from Acquisition import aq_parent
> >
> >class MyProduct(Folder):
> >    def index_html(self):
> >        print type(aq_parent) is None
> >        return "Hello World!"
> >
> >The first time I run this, it prints "False" to stdout because
> >ac_parent is of course a function.
> >BUT, if I refresh the product (no change made to the source) and run
> >this index_html() again it instead prints "True" because ac_parent has
> >become None.
> >Isn't that odd?
> Indeed, especially because no type can be "None"!
Oops! A typo.
It should be::

  def index_html(self):
       print aq_parent is None
       return "Hello World!"

> It is known that refreshing (more generally reloading a Python module)
> can cause objects apparently becoming "None".
> This happens because the variables defined in the old module
> instance are rebound to None when the module is released.
> This would explain that "aq_parent" in your "index_html" would
> appear as None if you happen to access an object still associated
> with the old class. However, the type of "None" is "NoneType" and
> not "None".

> As written earlier: refreshing is essentially a Python feature
> (delete a set of modules from "sys.modules", then reimport some of
> them again) rather than a Zope feature.
> It should be possible to reproduce your weird observations
> with Python operations only.
> I tried but was not yet able to reproduce it (I still use Zope 2.8
> (but that should not matter) and Python 2.4.1).

I noticed that since zope 2.8, the function manage_performRefresh()
hasn't changed. The only difference I can see is that (my) zope 2.8.5
comes with ZODB 3.4.2 and my zope 2.9.0 comes with ZODB 3.6.0.
The code is this::

 if RefreshFuncs.performFullRefresh(self._p_jar, self.id):
    from ZODB import Connection
    Connection.resetCaches() # Clears cache in future connections.
    message = 'Product refreshed.'

There is no code difference in RefreshFuncs.performFullRefresh()
between zope 2.8.5 and zope 2.9.0.

If someone can guide me I'd like to dig deeper into
ZODB.Connection.resetCaches() to see if there's be a big difference in
version 3.6 that might have caused my beloved refresh to stop working.

Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to