[ZOPE] External Method process limits? bug fix!
missive at frontiernet.net
Wed Jul 11 22:26:19 CEST 2001
Thanks for your help. I finally broke down and joined the zope mailing list.
It was not so difficult, really, just fill out the form at:
and reply to the confirmation message that goes out to you.
Turns out there is a bug in the PIL External Method example in the Zope
Book. Once the image.data attribute gets to a certain size, it is no
longer pushed around as a string, but gets wrapped up in its own
different kind of object. PIL or cStringIO was objecting to that.
The fix is to wrap image.data in str() to force stringiness.
Here is the corrected code...
(mostly from http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml)
def makeThumbnail(self, original_id, size=128):
Makes a thumbnail image given an image Id when called on a Zope
The thumbnail is a Zope image object that is a small JPG
representation of the original image. The thumbnail has a
'original_id' property set to the id of the full size image
from PIL import Image
from cStringIO import StringIO
# create a thumbnail image file
original_file=StringIO(str(original_image.data)) # bug fix here
# create an id for the thumbnail
thumbnail_id=path + '.thumb.jpg'
# if there's and old thumbnail, delete it
if thumbnail_id in self.objectIds():
# create the Zope image object
# set the 'originial_id' property
More information about the Python-list