[Zope] how to block until an image is done uploading?

Roman Milner roman@speeder.com
24 Oct 1999 12:22:16 -0500


>>>>> "MP" == Michel Pelletier <michel@digicool.com> writes:

    >> -----Original Message----- From: Roman Milner

    MP> Hmm..this is some pretty weird behavior.

    >>  Thanks, ^Roman
    >> 
    >> 
    >> def make_pictures(self, pic_folder, id, file):
    >> pic_folder.manage_addImage(id + '_thumbnail', file, id +
    >> '_thumbnail') pic_folder.manage_addImage(id, file, id)
    >> self._thumbnailize(getattr(pic_folder, id + '_thumbnail'))

    MP> Instead of using the Zope object, why don't you create the
    MP> thumbnail with 'file'?

Well, I figured it out.  It was just my not understanding how things
work.  The data was getting wrapped in Pdata() because it was bigger
than 1<<16.  So I had to do this:

    def thumbnailize(self, pic_folder, emp_id):
        imgOBJ = getattr(pic_folder, emp_id + '_thumbnail')
        try:
            out = StringIO.StringIO()
            if type(imgOBJ.data) == type(''):
                inn = StringIO.StringIO(imgOBJ.data)
            else:
                r=[imgOBJ.data.data]
                next = imgOBJ.data.next
                while next is not None:
                    self=next
                    r.append(self.data)
                    next=self.next
                inn = StringIO.StringIO(string.join(r,''))
            im = PIL.Image.open(inn)
            im.thumbnail((128,128))
            im.save(out, im.format)
            imgOBJ.update_data(out.getvalue())
        except IOError:
            imgOBJ.update_data('')


And that did the trick.  I just needed to read the source a little
more.  Thanks for your help.

^Roman