[Zope-dev] Re: cStringIO strange errors

Tres Seaver tseaver at zope.com
Fri Jul 9 13:48:23 EDT 2004


Tor Oskar Wilhelmsen wrote:
> Hi
> I'm using the code below to fetch an image from a database, and for inserting the image as an Image object in ZOPE. The strange thing is that the code causes python to crash, but sometimes it work (for 1 of 10 or something like that). Im using Python 2.3.3 for Windows and Zope 2.7.0 for windows. I don't get any indication about what causing the error, but testing leaves me with an error on the code below. Does anyone know what  I have done wrong?
> 
> imthumb = PIL.Image.open(StringIO(pic[3]))            #pic[3] is the blob from the db
> imthumb.thumbnail(tsize)                                    
> btfil = StringIO()
> imthumb.save(btfil,"JPEG")
> btfil.seek(0)
> #thumbnail title
> thumbnailtitle = str(pic[1])
> self.manage_addProduct['OFSP'].thumbnails.manage_addImage(thumbnailid,btfil,thumbnailtitle,"","image/jpeg")
> btfil.close()

I suggest you run Zope under gdb, as per:

   http://zope.org/Members/matt/StabilityHOWTO

which should give you some sense of what in particular is crashing.

I also don't know what that '.thumbnails' bit is doing in your 
invocation of the product / factory dispatcher.  If the intent is to 
have the image created in the 'thumbnails' subfolder of 'self', then I 
would spell your invocation as:

   dispatcher = self.thumbnails.manage_addProduct['OFSP']
   dispatcher.manage_addImage( .... )

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope-Dev mailing list