[Zope] System Error from Zope Book Example

Chris McDonough chrism@zope.com
Mon, 18 Feb 2002 12:59:15 -0500


Dan,

Put a print statement like so above the line:

  original_file=StringIO(original_image.data)

that reads:

  print type(original_image.data)

And let us know the results of the iteration on which it fails.

... passing something "wrong" into StringIO seems to be what's breaking your
code.

----- Original Message -----
From: "Dan Shafer" <dan@gui.com>
To: "Chris Withers" <chrisw@nipltd.com>
Cc: <zope@zope.org>
Sent: Monday, February 18, 2002 12:06 PM
Subject: Re: [Zope] System Error from Zope Book Example


> At 7:48 AM +0000 2/18/02, Chris Withers wrote:
> >Dan Shafer wrote:
> >>
> >>     File /home/dshafer/Zope-2.3.3-src/Extensions/Thumbnail.py, line 16,
> >>  in makeThumbnail
> >
> >Can you paste the code from Thumbnail.py here?
> >
> >(specifically, lines 10-20 ;-)
>
> Sure. Sorry. I had done this in my original message and in an effort
> to conserve bandwidth I guess I made it harder for people to help.
>
> Sigh.
>
> Here's the code; I've eliminated the docstring so the first
> executable line in the function appears on line 10 of the original
> code.
>
> def makeThumbnail(self, original_id, size=128)
>
> 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 an 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 'original_id' property
> thumbnail_image.manage_addProperty('original_id',
> original_id, 'string')
>
>
> >cheers,
> >
> >Chris
>
>
> --
> Dan Shafer, Personal Creativity Trainer and Consultant
> Trained Hartman Value Profile Analyst
> http://www.danshafer.com/valueprofile.html
>
> _______________________________________________
> 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 )
>