[Zope] Refreshing modules imported into external methods
Michael Hartl
michael_hartl at yahoo.com
Wed Dec 17 13:29:02 EST 2003
Thanks for the responses to my question.
> Have you tried this? Go to its manage page and hit 'Save changes'.
> Running Zope in debug mode (-D) may help too but I'm not sure.
Unfortunately, neither of those things worked.
> create a refreshing External Method that uses Python's "reload" to reload
> modules
This worked. It seems strange from a Python perspective, since there's no
need to use "reload" inside ordinary programs; Python automatically
re-imports any code that has changed. The "reload" function is ordinarily
only useful when working interactively with the interpreter. But it works
beautifully in this case.
Returning to my previous example:
external method file foo.py (located in /path_to_Zope/Extensions):
import bar
def foo():
reload(bar) # Reload module 'bar' as per Dieter's suggestion.
return 'foo' + bar.baz()
Python module bar.py (located on my PYTHONPATH):
def baz():
return 'bar'
Now changes to bar.py are reflected immediately in calls to foo(), without
restarting Zope.
Thanks again,
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