[Zope] Zope Product to globally add/remove a property
Gary Duke Speer
gspeer at cortech.org
Tue Jun 15 10:42:03 EDT 2004
Just the concept I was looking for. Thank you for steering me to the
rights tools for the project!
Gary
----- Original Message -----
From: "Roché Compaan" <roche at upfrontsystems.co.za>
To: "Gary Duke Speer" <gspeer at cortech.org>
Cc: <zope at zope.org>
Sent: Monday, June 14, 2004 11:48 AM
Subject: Re: [Zope] Zope Product to globally add/remove a property
> * Gary Duke Speer <gspeer at cortech.org> [2004-06-12 18:47]:
> > Does one of the many Zope products have a feature to walk a tree of
> > folderish objects and globally add or remove a named property.
> >
> > The delete would simply take the property name as an arguement and
execute
> > on all folders having the property from the point of execution down.
> > The add would take the Property name, the class, and the
default/starting
> > value and it it doesn't already exist, adds it.
> >
> > In the alternative, for a python newbie, is this something that can be
> > created easily? Is there a trick for error suppression needed to
manage
> > the cases of deleting when the property doesn't exist or adding when
> > already added during the recursion through subfolders. (or testing
first)
> >
> > Thank you for any suggestions,
> > Gary
>
> Add a python script that uses ZopeFind to find all folderish objects and
> add/delete properties to them:
>
> # rootfolder is the root of your tree
> for obj in context.ZopeFind(rootfolder,
> obj_expr='isPrincipiaFolderish', search_sub=1):
> # add new properties
> if not obj.hasProperty('NewPropertyName'):
> obj.manage_addProperty('NewPropertyName', '', 'string')
> # delete properties
> if obj.hasProperty('PropertyToDelete'):
> obj.manage_delProperty('PropertyToDelete')
>
> --
> Roché Compaan
> Upfront Systems http://www.upfrontsystems.co.za
More information about the Zope
mailing list