[Zope-dev] Zope Product Reload
Andrew Lahser
andrew@apl-software.com
10 Feb 2000 23:03:03 -0000
I understand its possible to reload a module with python.
Theoretically, it should be possible to reload a Zope Product
without restarting Zope.
I would like to develop a Product/Patch/External Method that
would allow this. After a couple hours of research, I have
more questions than answers. If anyone has looked at this,
I would appreciate some insight.
Here are a few questions.
1. It appears that Zope puts in its own __import__ and reload
hooks, is this correct? Why does Zope do this?
2. Just setting up a simple method, such as the following
doesn't work either.
import Products
from CStringIO import StringIO
def manage_reload(self, product_name, REQUEST=None):
"""Reload a Product without restarting Zope"""
if hasattr(Products, product_name):
product=getattr(Products,product_name)
else:
return 'Product not found'
modules=sys.modules
try:
reload(product)
except:
f=StringIO()
traceback.print_exc(100,f)
f=f.getvalue()
try: modules[pname].__import_error__=f
except: pass
The strange thing about this method is that the module DOES
get reloaded, but the new module doesn't appear to get used.
Very puzzling!
Mostly, I am wondering if anyone else has tried or thought
about this problem. Developing products can take many, many
iterations, and I am just tired of waiting the three or four
seconds for Zope to restart.
Drew