[Zope] Re: Adding Properties to Folder Objects via a Zope Python Script

Evan Simpson evan@4-am.com
Thu, 30 Jan 2003 16:34:14 -0600


Asad Habib wrote:
> Hi. I was wondering whether any of you know if it is
> possible to create properties for Folder objects using
> a Zope Python script

The answer is yes, and applies more generally.  In other words, you can 
write a Script to do just about anything that can be done through the 
ZMI.  Here's how:

Go to the Properties tab of some Folder in the ZMI.  Use your browser's 
"View Source" ability, and examine the form at the bottom of the page. 
Its action is the path to the Folder plus "manage_addProperty".  The 
fields submitted are "id", "type", and "value".  The "type" select box 
lists the values that it accepts.  The ":string" and similar modifiers 
on the field names indicate the types that the method is expecting.

 From this, you can guess that the following code will probably add an 
integer property with the value 42:

folder.manage_addProperty(id='foo', type='int', value='42')

...as, in fact, it does.  Also, now that you know the method name, you 
can look it up in the API reference at:

http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixB.stx

...for more information.

Cheers,

Evan @ 4-am