How to convert an Image to an Photo programmatically ?
Hi, I have a bunch of images in the ZODB, which I want to convert to Photos in the Photo product. The following script: request = context.REQUEST # Upgrade Photos for photo in context.objectItems(['Image']): # Convert old photo object to new. print photo photoid = photo[0] photo = photo[1] if photo.data: id = context.Photos.manage_addProduct['Photo'].manage_addPhoto( photoid, photo.title, photo.data, store='Image', engine='PIL', REQUEST=request) ##newphoto = getattr(context, id) results in: Error Type: AttributeError Error Value: read ..... File /usr/local/ZopePark/tozo2.aixtraware.de/ZInstanceHome/Products/Photo/Photo. py, line 654, in manage_addPhoto Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163 -------------------------------------------------------------------- Key fingerprint = DA10 CC82 62F8 1DBB 39A1 1EDC 725B 3317 A8D7 C3A6 Keyserver: http://germany.keyserver.net/en/
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Joachim Schmitz
I have a bunch of images in the ZODB, which I want to convert to Photos in the Photo product.
Error Type: AttributeError Error Value: read
There is a problem with Photo 1.2.3 that breaks what you're doing. Apply the following changes to fix it: In Photo.py, manage_addPhoto(), replace the following line: photo._data = file.read() with this: try: photo._data = file.read() except AttributeError: photo._data = file _______________________ Ron Bickers Logic Etc, Inc.
thanks, that did the trick for images under 64kb, the following works for all images: try: photo._data = file.read() except AttributeError: if type(file) is type(''): photo._data = file else: photo._data = file.data file=file.next while file is not None: photo._data += file.data file=file.next --On Donnerstag, März 21, 2002 10:09:00 -0500 Ron Bickers <rbickers-dated-1017328138.23aa81@logicetc.com> wrote:
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Joachim Schmitz
I have a bunch of images in the ZODB, which I want to convert to Photos in the Photo product.
Error Type: AttributeError Error Value: read
There is a problem with Photo 1.2.3 that breaks what you're doing. Apply the following changes to fix it:
In Photo.py, manage_addPhoto(), replace the following line:
photo._data = file.read()
with this:
try: photo._data = file.read() except AttributeError: photo._data = file
_______________________
Ron Bickers Logic Etc, Inc.
Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163 -------------------------------------------------------------------- Key fingerprint = DA10 CC82 62F8 1DBB 39A1 1EDC 725B 3317 A8D7 C3A6 Keyserver: http://germany.keyserver.net/en/
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
thanks, that did the trick for images under 64kb, the following works for all images:
Ah, yes. The Image "parts" don't work with my initial fix. This will do the job as well. try: photo._data = file.read() except AttributeError: photo._data = str(file) Thanks! _______________________ Ron Bickers Logic Etc, Inc.
participants (3)
-
Joachim Schmitz -
Ron Bickers -
Ron Bickers