Photo Product: Can't convert images.
Hi, I'm using the Photo Folder product, and I'm trying to convert a number of jpg's by using the "Python Script" shown in the README.txt for the product: """Convert all Image objects in folder to Photo objects""" for image in context.objectValues(['Image']): context.manage_delObjects([image.getId(),], REQUEST=context.REQUEST) context.manage_addProduct['Photo'].manage_addPhoto(image.getId(), image.title, image.data, REQUEST=context.REQUEST) I get the following error when calling the Image2Photo script on the folder: Error Type: AttributeError Error Value: 'string' object has no attribute 'read' <!-- Traceback (innermost last): File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/Zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: Image2Photo) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: Image2Photo) File /usr/local/Zope/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: Image2Photo) File /usr/local/Zope/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: Image2Photo) File /usr/local/Zope/lib/python/Products/PythonScripts/PythonScript.py, line 336, in _exec (Object: Image2Photo) (Info: ({'script': <PythonScript instance at 8b81a20>, 'context': <PhotoFolder instance at 8c3cc60>, 'container': <CMFSite instance at 8dcdfc0>, 'traverse_subpath': []}, (), {}, None)) File Script (Python), line 7, in Image2Photo (Object: DSC00350.JPG) File /var/zope/Products/Photo/Photo.py, line 654, in manage_addPhoto AttributeError: (see above) --> And line 654 in Photo.py is photo._data = file.read() in manage_addPhoto python method. I'm using ExtFile and the ImageMagick engine. Can anyone see what I'm doing wrong, or what I need to fix? Thanks Regards Mark Simpson
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Mark Simpson
I'm using the Photo Folder product, and I'm trying to convert a number of jpg's by using the "Python Script" shown in the README.txt for the product:
I get the following error when calling the Image2Photo script on the folder:
Error Type: AttributeError Error Value: 'string' object has no attribute 'read'
Can anyone see what I'm doing wrong, or what I need to fix?
You're not doing anything wrong. As someone else has pointed out, I broke this capability in version 1.2.3 while trying to add some other feature. This is completely untested, but try replacing line 654 with the following and let me know if it works: try: photo._data = file.read() except AttributeError: photo._data = file I'll fix this one way or another in the next version, but I don't know when that will be. _______________________ Ron Bickers Logic Etc, Inc.
Thanks Ron. Worked a treat! Thanks for a wonderful product. Finally I've found a photo product that is configurable and does just what I want. I.E. Store one image (and the additional images are created automatically). Regards Mark Simpson On January 25, 2002 11:34 pm, you wrote:
You're not doing anything wrong. As someone else has pointed out, I broke this capability in version 1.2.3 while trying to add some other feature.
This is completely untested, but try replacing line 654 with the following and let me know if it works:
try: photo._data = file.read() except AttributeError: photo._data = file
Looks like a bug. You may replace line 654 in Photo.py with: if type(file) == 'instance': photo._data = file.read() else: photo._data = str(file) Ausum ----- Original Message ----- From: "Mark Simpson" <zdp@bowfort.com> To: <zope@zope.org> Sent: Friday, January 25, 2002 11:38 PM Subject: [Zope] Photo Product: Can't convert images.
Hi,
I'm using the Photo Folder product, and I'm trying to convert a number of jpg's by using the "Python Script" shown in the README.txt for the product:
"""Convert all Image objects in folder to Photo objects"""
for image in context.objectValues(['Image']): context.manage_delObjects([image.getId(),], REQUEST=context.REQUEST) context.manage_addProduct['Photo'].manage_addPhoto(image.getId(), image.title, image.data, REQUEST=context.REQUEST)
I get the following error when calling the Image2Photo script on the folder:
Error Type: AttributeError Error Value: 'string' object has no attribute 'read'
<!--
Traceback (innermost last): File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/Zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: Image2Photo) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: Image2Photo) File /usr/local/Zope/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: Image2Photo) File /usr/local/Zope/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: Image2Photo) File /usr/local/Zope/lib/python/Products/PythonScripts/PythonScript.py, line 336, in _exec (Object: Image2Photo) (Info: ({'script': <PythonScript instance at 8b81a20>, 'context': <PhotoFolder instance at 8c3cc60>, 'container': <CMFSite instance at 8dcdfc0>, 'traverse_subpath': []}, (), {}, None)) File Script (Python), line 7, in Image2Photo (Object: DSC00350.JPG) File /var/zope/Products/Photo/Photo.py, line 654, in manage_addPhoto AttributeError: (see above)
-->
And line 654 in Photo.py is photo._data = file.read() in manage_addPhoto python method.
I'm using ExtFile and the ImageMagick engine.
Can anyone see what I'm doing wrong, or what I need to fix?
Thanks Regards Mark Simpson
_______________________________________________ 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 )
participants (3)
-
Ausum -
Mark Simpson -
Ron Bickers