[Zope] System Error from Zope Book Example

Dan Shafer dan@gui.com
Mon, 18 Feb 2002 12:47:06 -0800


At 12:59 PM -0500 2/18/02, Chris McDonough wrote:
>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.

Nothing ever prints. Not sure where it _would_ print. But the error persists.

It's obvious to me either that I just don't get something fundamental 
about Zope and how it deals with scripts and External Methods or 
there's some kind of major flaw in the scripts in the Zope Book that 
I am too inexperienced to dope out.

The earlier error I reported (bad argument to internal function) 
disappeared when I deleted the JPEG it was processing at the time. 
Must have been something wrong with it, though it displayed just fine.

The thing is, the scripts I'm talking about actually run. They create 
the thumbnail(s). Then they cause an error. The new error (which is 
the second one I reported last week) says that I'm trying to download 
a CGI application. This error arises _after_ the thumbnails are 
created.

This error occurs on all browsers and all platforms that I can test.

i'm going to test with a small, known-working external script later 
today and see if this is a config problem of some sort. But I've 
already concluded one thing: external scripts are too hard to use 
because there's no way to debug them.

>----- 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 )
>  >


-- 
Dan Shafer, Personal Creativity Trainer and Consultant
Trained Hartman Value Profile Analyst
http://www.danshafer.com/valueprofile.html