[Zope-dev] Zope Product Reload

Steve Spicklemire steve@spvi.com
Thu, 10 Feb 2000 23:37:33 -0500 (EST)


Hmmm... I think the reload does reload the module, so that
any *new* instances created from classes in that module
will use the new code *but* any old instances (in memory), will still
refer to the old class definitions. You will need to flush
all these from memory and re-instantiate them to get
them to use the new module... or somehow go through all the
instances and replace their __class__ with the new version.

-steve

>>>>> "Andrew" == Andrew Lahser <andrew@eventera.com> writes:

    Andrew> I understand its possible to reload a module with python.
    Andrew> Theoretically, it should be possible to reload a Zope
    Andrew> Product without restarting Zope.

    Andrew> I would like to develop a Product/Patch/External Method
    Andrew> that would allow this. After a couple hours of research, I
    Andrew> have more questions than answers. If anyone has looked at
    Andrew> this, I would appreciate some insight.

    Andrew> Here are a few questions.

    Andrew> 1. It appears that Zope puts in its own __import__ and
    Andrew> reload hooks, is this correct? Why does Zope do this?
    Andrew> 2. Just setting up a simple method, such as the following
    Andrew> doesn't work either.

    Andrew> import Products from CStringIO import StringIO

    Andrew> def manage_reload(self, product_name, REQUEST=None):
    Andrew> """Reload a Product without restarting Zope""" if
    Andrew> hasattr(Products, product_name):
    Andrew> product=getattr(Products,product_name) else: return
    Andrew> 'Product not found' modules=sys.modules try:
    Andrew> reload(product) except: f=StringIO()
    Andrew> traceback.print_exc(100,f) f=f.getvalue() try:
    Andrew> modules[pname].__import_error__=f except: pass

    Andrew> The strange thing about this method is that the module
    Andrew> DOES get reloaded, but the new module doesn't appear to
    Andrew> get used.

    Andrew> Very puzzling!

    Andrew> Mostly, I am wondering if anyone else has tried or thought
    Andrew> about this problem. Developing products can take many,
    Andrew> many iterations, and I am just tired of waiting the three
    Andrew> or four seconds for Zope to restart.

    Andrew> Drew

    Andrew> _______________________________________________ Zope-Dev
    Andrew> maillist - Zope-Dev@zope.org
    Andrew> http://lists.zope.org/mailman/listinfo/zope-dev ** No
    Andrew> cross posts or HTML encoding!  ** (Related lists -
    Andrew> http://lists.zope.org/mailman/listinfo/zope-announce
    Andrew> http://lists.zope.org/mailman/listinfo/zope )