Adding Properties to Folder Objects via a Zope Python Script
Hi. I was wondering whether any of you know if it is possible to create properties for Folder objects using a Zope Python script that can then be invoked from a DTML method. I know that this is possible using Zope's management interface, but this procedure is not scalable. Any input would be appreciated. Thanks. -Asad __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
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
On Thu, Jan 30, 2003 at 01:52:14PM -0800, 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 that can then be invoked from a DTML method. I know that this is possible using Zope's management interface, but this procedure is not scalable. Any input would be appreciated. Thanks.
Of course. :) see the 2.6 version of the zope book, "Advanced Scripting" chapter. http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ScriptingZope.st... search for "new property" and you'll find it. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's PETULANT ACTION-FILLED POISON MONKEY! (random hero from isometric.spaceninja.com)
On Thu, 2003-01-30 at 19:52, 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 that can then be invoked from a DTML method. I know that this is possible using Zope's management interface, but this procedure is not scalable. Any input would be appreciated. Thanks.
In your PythonScript, call theFolder.manage_addProperty(id=<property-id>, value=<property-value>, type=<property-type>) later on, when you need to change a property, you can call: theFolder.manage_changeProperties(<property-id>=<property-value>) For more information on managing properties, read the file <your zope>/lib/python/OFS/PropertyManager.py Cheers, Leo -- Ideas don't stay in some minds very long because they don't like solitary confinement.
participants (4)
-
Asad Habib -
Evan Simpson -
Leonardo Rochael Almeida -
Paul Winkler