[Zope] Refreshing modules imported into external methods
Michael Hartl
michael_hartl at yahoo.com
Fri Dec 12 16:39:43 EST 2003
I'm having trouble getting Zope to refresh modules imported into my external
methods. I've googled at length, read the fine manual, and searched the
list archives, all to no avail. Here is the situation:
external method file foo.py (located in /path_to_Zope/Extensions):
import bar
def foo():
return 'foo' + bar.baz()
Python module bar.py (located on my PYTHONPATH):
def baz():
return 'bar'
Now if I look at http://localhost:8080/foo, I see 'foobar', and if I edit
foo.py to change 'foo' to 'fu', my browser (after refreshing) displays
'fubar'. The problem is that when I edit bar.py and change 'bar' to 'baz', I
still see 'fubar', not 'fubaz'. In other words, Zope incorporates changes to
my external method (foo.py), but not to its imported module (bar.py).
It seems that Zope is caching the result of importing bar.py, because when I
restart Zope the changes to bar.py show up in my browser. Restarting Zope
after every change to an external module is a possible but extremely
cumbersome solution to my problem. Does anyone know how to get Zope to
re-import modules that have changed? I tried removing the Python bytecode
(bar.pyc in this case), but that didn't work.
I might be able to avoid this problem by developing a Zope product and
forcing my method to be volatile using _v_, but many of the modules I want to
import are for general use and are not Zope-specific. I am loath to tie them
to Zope.
Michael
=====
Michael Hartl
http://www.michaelhartl.com/
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
More information about the Zope
mailing list