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

D2 borelan@wanadoo.fr
Thu, 15 May 2003 11:37:02 -0400

To answer Jean-Francois's question :
I tried this in the __init__.py of a product in initialize

     props=({'id':''Property_1', 'value':'1', 'type':'string'},
            {'id':''Property_2', 'value':'2', 'type':'string'}
     for property in props:
         product._setProperty(property['id'], property['value'],

it works!

To answer Chris,

 >>> And, more usefully, what are you actually trying to achieve here?

I have a vague idea of creating some program to automate some repetitive 
tasks and accelerate the production process by generating programs, 
pieces of programs or customization, by using description tools of my own.
So i try several things, i dive into Python, Zope.
Some of my 'work of art' are useles, some can become useful.

I have a tree-maker to wich i pass a text file with a simple description 
of my tree, the folder content, the constructors, the properties and so 
on. The tree is generated, all objects are set in their respective 
That's better than repeating
object=Folder(id, title)
and another one and then create contained objects...Pfff!

I have a special format, (not yet completed) wich will be like this :
   Object_n, class, constructor
     functions and methods
Object_n+n, class, and so on...

The functions are created independently in a special method repository 

It's like a puzzle, each piece is developed or described independently 
and the tool rebuild the puzzle following the description.

It won't be a universal tool but it will help for basic, repetitive 
silly tasks.

I don't know if it's clear or useful but it'a an answer to your question.

PS : I modify my function without exec:
def add_ClassProperty(product, module, some_class, property, value)
     object=__import__('module', globals(), globals(),
     setattr(klass, property, value)

Do you feel better ?