Changing External Python Methods
Hello, I'm fiddling arround with some External Python Methods and I have to admit that it is a real pain to debug those Methods - at least I did not found a reasonable way. It makes me really crazy ist the fact that it seems that Zope just caches the first version of the file which I putted into the Extensions directory and later changes are simply ignored. For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a. Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif' Well, besides the fact that I would like to know how to reference those files I really want to know why the following code stolen from http://www.zopelabs.com/cookbook/1010702887 works def MakeThumbHi2(self, image="test"): oriImage = self.restrictedTraverse(image) oriFile = cStringIO.StringIO(oriImage.data) image = PIL.Image.open(oriFile) image.thumbnail(100, 100) image_type = image.format thumbnailImage = cStringIO.StringIO() image.save(thumbnailImage, image_type) thumbnailImage.seek(0) return thumbnailImage.getvalue() and if I just replace my very own External Method by just this code snipped (please note: there is no string 'bland.gif' in it - it was just in my former broken code) I get the very same error message with the missing file 'bland.gif'. It seems that there is something cached and I would like to know how to get the changed version into this cache. Moreover it would be nice to enlighten me about some other way to reference files in the same ZMI folder from External Methods besides this way to ship a parameter. Kind regards Andreas.
update you script in the ZMI after changes. zope doesn't monitor your file system, you have to tell zope that you made changes to the file. regards gidon Andreas Tille schrieb:
Hello,
I'm fiddling arround with some External Python Methods and I have to admit that it is a real pain to debug those Methods - at least I did not found a reasonable way. It makes me really crazy ist the fact that it seems that Zope just caches the first version of the file which I putted into the Extensions directory and later changes are simply ignored.
For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a.
Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif'
Well, besides the fact that I would like to know how to reference those files I really want to know why the following code stolen from http://www.zopelabs.com/cookbook/1010702887 works
def MakeThumbHi2(self, image="test"):
oriImage = self.restrictedTraverse(image) oriFile = cStringIO.StringIO(oriImage.data)
image = PIL.Image.open(oriFile) image.thumbnail(100, 100) image_type = image.format
thumbnailImage = cStringIO.StringIO() image.save(thumbnailImage, image_type) thumbnailImage.seek(0)
return thumbnailImage.getvalue()
and if I just replace my very own External Method by just this code snipped (please note: there is no string 'bland.gif' in it - it was just in my former broken code) I get the very same error message with the missing file 'bland.gif'. It seems that there is something cached and I would like to know how to get the changed version into this cache. Moreover it would be nice to enlighten me about some other way to reference files in the same ZMI folder from External Methods besides this way to ship a parameter.
Kind regards
Andreas.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
If you run zope in "Debug" mode (-D switch on start), then it will check the file everytime the external method is executed, reloading it if it has changed. -Casey On Monday 09 September 2002 09:51 am, Gidon Friedman wrote:
update you script in the ZMI after changes. zope doesn't monitor your file system, you have to tell zope that you made changes to the file.
regards
gidon
Andreas Tille schrieb:
Hello,
I'm fiddling arround with some External Python Methods and I have to admit that it is a real pain to debug those Methods - at least I did not found a reasonable way. It makes me really crazy ist the fact that it seems that Zope just caches the first version of the file which I putted into the Extensions directory and later changes are simply ignored.
For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a.
Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif'
Well, besides the fact that I would like to know how to reference those files I really want to know why the following code stolen from http://www.zopelabs.com/cookbook/1010702887 works
def MakeThumbHi2(self, image="test"):
oriImage = self.restrictedTraverse(image) oriFile = cStringIO.StringIO(oriImage.data)
image = PIL.Image.open(oriFile) image.thumbnail(100, 100) image_type = image.format
thumbnailImage = cStringIO.StringIO() image.save(thumbnailImage, image_type) thumbnailImage.seek(0)
return thumbnailImage.getvalue()
and if I just replace my very own External Method by just this code snipped (please note: there is no string 'bland.gif' in it - it was just in my former broken code) I get the very same error message with the missing file 'bland.gif'. It seems that there is something cached and I would like to know how to get the changed version into this cache. Moreover it would be nice to enlighten me about some other way to reference files in the same ZMI folder from External Methods besides this way to ship a parameter.
Kind regards
Andreas.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Casey Duncan writes:
If you run zope in "Debug" mode (-D switch on start), then it will check the file everytime the external method is executed, reloading it if it has changed. However, it is unwilling to take notice of signature changes (e.g. changes in the number of parameters, or changing their mandatory/with default state).
This is probably a bug which I did not yet file to the collector... Dieter
This has been fixed in the CVS trunk for both 2.6 and 2.5, if you still observe the behavior, let me know. -Casey On Monday 09 September 2002 02:00 pm, Dieter Maurer wrote:
Casey Duncan writes:
If you run zope in "Debug" mode (-D switch on start), then it will check the file everytime the external method is executed, reloading it if it has changed. However, it is unwilling to take notice of signature changes (e.g. changes in the number of parameters, or changing their mandatory/with default state).
This is probably a bug which I did not yet file to the collector...
Dieter
On Mon, Sep 09, 2002 at 02:54:53PM +0200, Andreas Tille wrote:
Hello,
I'm fiddling arround with some External Python Methods and I have to admit that it is a real pain to debug those Methods - at least I did not found a reasonable way. It makes me really crazy ist the fact that it seems that Zope just caches the first version of the file which I putted into the Extensions directory and later changes are simply ignored.
You need to go to the ZMI page for your external method and click "Save Changes". The python file will get reloaded. --PW -- Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
On Mon, 9 Sep 2002, Andreas Tille wrote:
Hello,
I'm fiddling arround with some External Python Methods and I have to admit that it is a real pain to debug those Methods - at least I did not found a reasonable way. It makes me really crazy ist the fact that it seems that Zope just caches the first version of the file which I putted into the Extensions directory and later changes are simply ignored.
You need to keep pressing the 'Save Changes' button in the External Method's management screen, once every time you edit the method! I found this so irritating that I wrote a small hack to add a tab to the management interface to activate automatic refreshing; have a look at my How-To, http://www.zope.org/Members/madcow/ExtMethodRefresh. I hope you find this useful. I can't guarantee it's 100% bug-free; if you have any problems please do let me know (not at this address, which ceases to be valid in 3 weeks; contact me at loefflerdavid@hotmail.com). David Loeffler
Andreas Tille writes:
... For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a.
Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif' You cannot access file in the "Extension" folders with bare (relative) names. This has nothing to do with Zope but with you OS:
Relative file names are resolved with respect to the "current working directory". There are operating system commands to change it (which are unsafe in a multi-threaded environment (like Zope)!). Zope will use them only (if at all) during startup, before threads are started. It cannot follow the various extension folders. Dieter
On Mon, 9 Sep 2002, Dieter Maurer wrote:
For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a.
Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif' You cannot access file in the "Extension" folders with bare (relative) names. This has nothing to do with Zope but with you OS: No. BUt I have installed the file in ZMI in the same folder as the External Method is defined in - not in the Extension folder.
Kind regards Andreas.
Andreas Tille writes:
On Mon, 9 Sep 2002, Dieter Maurer wrote:
For instance I just try to do some processing onto an image named bland.gif which is in the same folder of ZMI as the External Method. I've got a.
Error Type: IOError Error Value: [Errno 2] No such file or directory: 'bland.gif' You cannot access file in the "Extension" folders with bare (relative) names. This has nothing to do with Zope but with you OS: No. BUt I have installed the file in ZMI in the same folder as the External Method is defined in - not in the Extension folder. Apparently, you use "open" to open this file.
"open" interprets its argument as a file name in the filesystem. It is to be expected that it does not find the file there... Use "str(fileobject.data)" to access the content of a Zope file object "fileobject". Dieter
participants (6)
-
Andreas Tille -
Casey Duncan -
DA Loeffler -
Dieter Maurer -
Gidon Friedman -
Paul Winkler