[Zope] Copying properties
Shai Berger
shai@aristocart.com
Thu, 02 Aug 2001 14:50:42 +0300
Hi Zopers,
Just in case someone ever wants to copy a whole set
of properties from one folder to another, here's what
I just did.
Put in the target folder this little python script:
"""
## Script (Python) "copy_props"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
source = context.path.to.source
for prop in source.propertyMap():
# Every prop is a dict
id = prop.get('id', '_no_id')
type = prop.get('type','string')
value = getattr(source, id, None)
if type not in ('selection', 'multiple selection'):
# Regular properties can just be set
context.manage_addProperty(id, value, type)
else:
# Selections need first be added, then set
select_variable = prop.get('select_variable','_no_select_variable')
context.manage_addProperty(id, select_variable, type)
context.manage_changeProperties({id:value})
REQUEST = context.REQUEST
return context.manage_propertiesForm(context,REQUEST,manage_tabs_message="Properties copied")
"""
Now, testing the script will copy the properties and put you
in the new and updated Properties tab of the target folder.
Thought you might be interested,
Shai.