[Zope] Add Property to Image with Form & Python?

Kevin Jones ktmi at earthlink.net
Thu Mar 25 11:12:25 EST 2004


Greetings-

(First, thanks to all who responded to my earlier question!)

Question:  I'm using a form to specify an Image and desired 
properties to upload. Then I use a Python script to do the actual 
_addImage and _addProperty.  The _addImage works fine.  But when 
I try to use the same script to add properties, I can't get it to 
work.  The only object I can successfully add to is the image's 
parent folder...

Here's what I have so far; the problem seems to be accessing the 
"id" of the image I created in the earlier lines of code:

(Form)
<form action ="image_action" ...>
<Image: <input type="file" name="file">
<Property: <input type="text" name="author">
<input type="submit" value ="Add Image"
________________________________________________

(image_action method)
<dtml-call expr="add_Image(file, author)">
________________________________________________

#add_Image Python script
#
from Products.PythonScripts.standard import url_quote
image_folder=container.form_images

#create the new image
image_folder.manage_addProduct['OFSP'].manage_addImage(id='', 
title='', file=file)

#add an author property to image created above
doc=getattr(image_folder, id)
doc.manage_addProperty('author', author, 'string')
_________________________________________________

Much thanks in advance!!  I'm learning a lot from you all.

Kevin




More information about the Zope mailing list