[Zope-CMF] Product properties: set and get ?

D2 borelan@wanadoo.fr
Fri, 09 May 2003 11:59:36 -0400


I tried this :

def add_ClassProperty(product, klass, property, value):
     """Change a class properties
        The class must have PropertyManager in its hierarchy
     """
     exec 'from %s import %s' % (product, klass)
     exec 'setattr(%s, property, value)' % (klass)
     exec '%s._properties=%s._properties+({\'id\':property, 
\'type\':\'string\'},)' % (klass, klass)


add_ClassProperty('OFS.Folder', \
                   'Folder', 'New_property', 'New Value')

It works with Folder and other classes i've tested
With PloneSite (from Products.CMFPlone.Portal, the proprety doesn't 
appear via the ZMI but i can't add a propety with the same name 
(Duplicate id error) so the proprety exists.
I don't know why t doesn't appear in manage_propertiesForm i think that 
may be linked with PloneSite behaviour or CustomizationPolicy. I d'nt 
know and i didn't search the reason.

HTH

Andre


Chris Withers a écrit:
> Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:
> 
>> I have tried putting an _properties tuple of dictionaries in my 
>> __init__.py:
>>
>> _properties = ( {'id': 'rasterimagesfsroot', 'type': 'string' }, {'id':
>> 'rasterimagesurlroot', 'type': 'string' }, )
>>
>> But that didn't do anything.
> 
> 
> Does your Product class include PropertyManager in it's hierarchy of 
> parents?
> 
>> How is this done ? Note that these should be properties of the product
>> itself (Edited through the properties tab of the product, in the control
>> panel), NOT of instances of the product.
> 
> 
> Ah, well, _properties won't do that and I dont' know of a way that it 
> would be possible.
> 
> This is quite an unusualy requirement. What lead you to see it as a need?
> 
> cheers,
> 
> Chris
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
> 
> See http://collector.zope.org/CMF for bug reports and feature requests
>