Refreshing modules imported into external methods
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/
At 12/12/2003 13:39, you wrote:
I'm having trouble getting Zope to refresh modules imported into my external methods.
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. Gabriel Genellina Softlab SRL
Michael Hartl wrote at 2003-12-12 13:39 -0800:
I'm having trouble getting Zope to refresh modules imported into my external methods.
Zope's "refresh" works only on products. Your options: * create a refreshing External Method that uses Python's "reload" to reload modules or removes the module from "sys.modules". * move your modules into a Product and refresh this product using Zope's "refresh". In both cases, you will need to refresh your External Method explicitly after you reloaded/refreshed your module (by clicking its "Save" button). -- Dieter
participants (3)
-
Dieter Maurer -
Gabriel Genellina -
Michael Hartl