[ZOPE] External Method process limits?

Lee Harr missive at frontiernet.net
Sun Jul 8 17:35:29 EDT 2001


On Sun, 08 Jul 2001 17:03:30 +0200, Rene Pijlman <reageer.in at de.nieuwsgroep>:
> missive at frontiernet.net (Lee Harr) schreef:
>>Here is the error message I get:
>>Error Type: TypeError
>>Error Value: expected string, ImplicitAcquirerWrapper found
>>File /usr/local/www/Zope/Extensions/Thumbnail.py, line 18, in makeThumbnail
>>Any wisdom?
> 
> Yes, the error is on line 18 of
> /usr/local/www/Zope/Extensions/Thumbnail.py :-)
> 
> Post lines 1-25 if you want more help.


def makeThumbnail(self, original_id, size=128):
          """
          Makes a thumbnail image given an image Id when called on a Zope
          folder.

          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
          object.
          """

          from PIL import Image
          from cStringIO import StringIO
          import os.path

          # create a thumbnail image file
          original_image=getattr(self, original_id)
          original_file=StringIO(original_image.data)
          image=Image.open(original_file)
          image=image.convert('RGB')
          image.thumbnail((size,size))
          thumbnail_file=StringIO()
          image.save(thumbnail_file, "JPEG") 
          thumbnail_file.seek(0)

          # create an id for the thumbnail
          path, ext=os.path.splitext(original_id)
          thumbnail_id=path + '.thumb.jpg'

          # if there's and old thumbnail, delete it
          if thumbnail_id in self.objectIds():
              self.manage_delObjects(thumbnail_id)

          # create the Zope image object
          self.manage_addProduct['OFSP'].manage_addImage(thumbnail_id,
                                                         thumbnail_file,
                                                         'thumbnail image')
          thumbnail_image=getattr(self, thumbnail_id)

          # set the 'originial_id' property
          thumbnail_image.manage_addProperty('original_id', original_id, 'string
')

          return 'done' # I added this myself. Pretty clever, eh? ;)






More information about the Python-list mailing list