Hi everyone,
I'm using the Photo product to diplay some pictures at various resolutions
and to display them on a certain date. (Some may recall my questions about a
"Picture of the day" recently.) I want to set a 'display_date' property for
each Photo instance and I'd like to do it using a PythonScript. I've created
a form and PythonScript, but I get this error:
Error Type: TypeError
Error Value: argument 1: expected read-only character buffer, instance found
and this traceback:
Traceback (innermost last):
File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 187, in
publish
File /var/lib/zope/2.3.0/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 171, in
publish
File /var/lib/zope/2.3.0/lib/python/ZPublisher/mapply.py, line 160, in
mapply
(Object: POTD_add)
File /var/lib/zope/2.3.0/lib/python/ZPublisher/Publish.py, line 112, in
call_object
(Object: POTD_add)
File /var/lib/zope/2.3.0/lib/python/Shared/DC/Scripts/Bindings.py, line
324, in __call__
(Object: POTD_add)
File /var/lib/zope/2.3.0/lib/python/Shared/DC/Scripts/Bindings.py, line
353, in _bindAndExec
(Object: POTD_add)
File
/var/lib/zope/2.3.0/lib/python/Products/PythonScripts/PythonScript.py, line
330, in _exec
(Object: POTD_add)
(Info: ({'script': PythonScript instance at 87874d0,
'context': Folder instance at 89506c0, 'container': Folder instance at
89506c0, 'traverse_subpath': []}, ('This is a test',
DateTime('2001/01/30'), ZPublisher.HTTPRequest.FileUpload instance at
869e170), {}, None))
File Script (Python), line 8, in POTD_add
TypeError: (see above)
Here's the relevant part of the form:
form action="POTD_add" method="post" enctype="multipart/form-data"
table
tr
th align="right"Caption/th
tdinput type="text" name="title" size="50" value=""/td
/tr
tr
th align="right"Display Date/th
tdinput name="display_date:date" size="20" value=""/td
/tr
tr
th align="right"Image/th
tdinput type="file" name="file" size="25" value=""/td
/tr
tr
tdnbsp;/td
tdbrinput type="submit" value=" Add POTD "/td
/tr
/table
/form
And here's my PythonScript 'POTD_add' to which I pass the parameter list
'title, display_date, and file':
"""
Create a "Picture of the Day" image.
"""
import string
# create a unique object id based on the display date
newID = string.split(display_date, '/')
id = ''
for i in newID:
id = id + str(i)
# create the image
context.manage_addProduct['OFSP'].manage_addPhoto(id, title=title,
file=file)
# add a display date property
doc = getattr(context, id)
doc.manage_addProperty('display_date', display_date, 'date')
Any ideas?
Wouldn't it would be great if there was a PythonScript repository
somewhere? It would help me a ton.
-Tim
--
Tim Wilson | Visit Sibley online: | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN | | http://slashdot.org/
[EMAIL PROTECTED] | dtml-var pithy_quote | http://linux.com/
___
Zope maillist - [EMAIL PROTECTED]
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 )