how add properties via Python script? /kv
I'm trying to add the property "product" to all the images inside the "image_folder" with this line in Python: container.image_folder.objectValues(['Image']).manage_addProperty(produc t, name, string) but it does not work ... why? How should it be done? thanks! -- 'K:?
Kai Vermehr wrote:
I'm trying to add the property "product" to all the images inside the "image_folder" with this line in Python:
container.image_folder.objectValues(['Image']).manage_addProperty(produc t, name, string)
but it does not work ... why? How should it be done?
What you are doing above is that you try to add a propery to the list of images. What you want to do is to add a property to each image. for image in container.image_folder.objectValues(['Image']): image.manage_addProperty(product, name, string) Have you done the Python tutorial?
objectValues() returns a sequence of objects. You need to iterate over the sequence. On Wed, 5 Nov 2003, Kai Vermehr wrote:
I'm trying to add the property "product" to all the images inside the "image_folder" with this line in Python:
container.image_folder.objectValues(['Image']).manage_addProperty(produc t, name, string)
but it does not work ... why? How should it be done?
thanks! -- 'K:?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Kai Vermehr wrote:
I'm trying to add the property "product" to all the images inside the "image_folder" with this line in Python:
container.image_folder.objectValues(['Image']).manage_addProperty(produc t, name, string)
but it does not work ... why? How should it be done?
What you're asking Zope to call the manage_addProperty() method on a list, which of course does not have any such method. Instead, try this (untested): for object in container.image_folder.objectValues(['Image']): object.manage_addProperty(product, name, string) Cheers, - Michael Bernstein
participants (4)
-
Dennis Allison -
Kai Vermehr -
Lennart Regebro -
Michael Bernstein