[Zope-CMF] Add properties to already existing content types

Rainer Thaden Rainer Thaden <thadi@gmx.de>
Tue, 17 Jun 2003 18:22:03 +0200


Hi,

i had to add some properties to a file system based class which
already had some instances in the ZODB.
I did it like this:
I defined a function do_update in the class and called the method on
all instances.
Here's the code:

    def do_update(self):
        id = self.id

        container = self.aq_parent
        ob = self
        
        ob.__dict__ = self.__dict__
        ob.__dict__['property1']=''
        ob.__dict__['property2']=''
        
        container.manage_delObjects(ids=[id])
        container._setObject(id, ob)

The problem is that the new properties are tuples by default. When i
debug in the edit method of the class and assign

property1='bla'

then i get property1=('bla') at the first time.
When i assign it a second time i get the correct result.

Am i doing something wrong? Maybe the update method is a bit fragile?


-- 
Regards,
 Rainer                          mailto:thadi@gmx.de