[Zope] Changing object properties from Script (Python)

Charlie Reiman creiman@kefta.com
Wed, 8 Jan 2003 14:00:39 -0800


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Jon
> Whitener
> Sent: Wednesday, January 08, 2003 1:35 PM
> To: zope@zope.org
> Subject: [Zope] Changing object properties from Script (Python)
>
>
> (Newbie stops, wipes pieces of wall from forehead, and asks for help.)
>
> I'm stumped trying to use a Script (Python) to change the properties
> of a sequence of Zope objects.
>
> Here's the problem: certain objects (simple folderish objects of my
> 'Cable Channel' ZClass) have a property called 'categories' that needs
> to be in the form of a Python *list*.  In many instances, however, the
> property was saved as a *string*.  (For more detail, see my January 6
> post "Solution for 'in requires character as left operand' error".)
>
> In my Script (Python), I've been successful identifying the problem
> objects and retrieving from them their 'categories' string.  Also, I
> can convert the string into a "singleton" list.  Then I hit problems.
>
> I want to iterate over these objects, calling a method that will
> change each one's 'categories' property.  Hell if I can do this!

Are you trying to change property types? You can't do that with
changeProperies. You'll need to remove the property then add it back with
the correct type. Properties are typed even though python variables aren't.