[Zope] Artificially create a fileupload instance or batch convert ExtImages
Tim Hicks
tim@sitefusion.co.uk
Mon, 11 Feb 2002 00:58:26 -0000
<Gregor: mailed you directly coz you saved my bacon on something very
related last time :-)>
Is there an easy way to create a fileupload instance from a string? I am
trying to batch convert a load of ExtImage files to give them all different
sized preview images, but manage_addExtImage() doesn't accept a string.
Alternatively, if anyone has a better way to achieve what I want, I'm very
much open to suggestions.
Here's the script I've got.
----
for old_folder in container.photos.objectValues(['Folder']):
container.manage_addFolder(old_folder.getId())
new_folder = container[old_folder.getId()]
for extimage in old_folder.objectValues(['ExtImage']):
new_folder.manage_addProduct['ExtFile'].manage_addExtImage(id=extimage.getId
(), title=extimage.title, file=extimage.index_html(), create_prev=1,
maxx=400, maxy=400, ratio=1)
----
Running it gives me:
Error Type: TypeError
Error Value: open, argument 1: expected string without null bytes, string
found
<see traceback below>
Traceback (innermost last):
File C:\PROGRA~1\zope233\lib\python\ZPublisher\Publish.py, line 223, in
publish_module
File C:\PROGRA~1\zope233\lib\python\ZPublisher\Publish.py, line 187, in
publish
File C:\PROGRA~1\zope233\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
File C:\PROGRA~1\zope233\lib\python\ZPublisher\Publish.py, line 171, in
publish
File C:\PROGRA~1\zope233\lib\python\ZPublisher\mapply.py, line 160, in
mapply
(Object: resizer)
File C:\PROGRA~1\zope233\lib\python\ZPublisher\Publish.py, line 112, in
call_object
(Object: resizer)
File C:\PROGRA~1\zope233\lib\python\Shared\DC\Scripts\Bindings.py, line
324, in __call__
(Object: resizer)
File C:\PROGRA~1\zope233\lib\python\Shared\DC\Scripts\Bindings.py, line
354, in _bindAndExec
(Object: resizer)
File
C:\PROGRA~1\zope233\lib\python\Products\PythonScripts\PythonScript.py, line
336, in _exec
(Object: resizer)
(Info: ({'script': <PythonScript instance at 014B3F20>, 'context':
<BTreeFolder instance at 0CC01490>, 'container': <BTreeFolder
instance at 0CC01490>, 'traverse_subpath': []}, (), {}, None))
File Script (Python), line 6, in resizer
(Object: Traversable)
File C:\PROGRA~1\zope233\lib\python\Products\ExtFile\ExtImage.py, line 88,
in manage_addExtImage
(Object: Traversable)
File C:\PROGRA~1\zope233\lib\python\Products\ExtFile\ExtImage.py, line
321, in manage_file_upload
(Object: CatalogAware)
File C:\PROGRA~1\zope233\lib\python\Products\ExtFile\ExtFile.py, line 371,
in manage_file_upload
(Object: CatalogAware)
File C:\PROGRA~1\zope233\lib\python\Products\ExtFile\ExtFile.py, line 466,
in _copy
(Object: CatalogAware)
TypeError: (see above)