[Zope] Product refreshing in Zope 2.9

Peter Bengtsson peter at fry-it.com
Mon Jan 30 13:54:06 EST 2006


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?

Again, this is easily reproducable with
http://www.peterbe.com/zope/2.9-refresh-reproduction/MyProduct.tgz

Any idea anyone?



On 1/27/06, Dieter Maurer <dieter at handshake.de> wrote:
> Peter Bengtsson wrote at 2006-1-27 16:42 +0000:
> > ...
> >But, in that example they are using Five and I'm not. I've just got a
> >Zope 2.9 install and a python product that I started on before Five
> >even existed. Does that give us any hope for non-Five python products?
> >Anybody?
>
> I cannot believe that they were able to break refreshability
> of "normal" (non Five) products.
>
> Refreshing essentially works by removing the modules belonging
> to the product from "sys.module" and then reimporting the product.
>
> This may fail when product defined objects are held in registries
> (such as adapters) and are not overridden when the product is
> reimported. Maybe, such cases occur often with Five.
>
> Without Five, it is rather rare (product objects are often registered
> but usually, the reimport overrides the old no longer working entries).
>
> >I've tried pressing the little "Refresh" button in Control_Panel and
> >sure enough, the product is reloaded (I put some print statements in
> >the .py file) but not refreshed.
>
> "reloaded but not refreshed" means what?
>
> --
> Dieter
>


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com


More information about the Zope mailing list