Hi Paula, Usually, we want to have such questions in the main mailing list. Then lots of people can try to help you and the archived replies can help others in the future when they have similar questions you have now. Therefore, my reply goes to zope@zope.org, too. Paula Mangas writes:
.... But i am worried about the possible need of a future migration from the old ZODB to new one.
How can i do that? Is there any simple way to do it?
For example, if we have an object *xpto*, and this object has 2 attributes, *x* and *y*. If we create instanciations of *xpto* they will "stay" on ZODB; now, if i make a change on specification of *xpto* object, and i want one more attribute, suposing *w*; how can i "add" this attribute to the old object (i mean, the simple way to do that). I know that i can treat exception, and when i want to use the attribute *w*, if it is not defined, i can define it. But it seems, to me, that is not a very good solution... Whether this is simple depends on what your objects are.
If they are ZInstances, the problem is trivial. You simply add the new property to the ZClass' property sheet. All exisiting objects just see the default value define in the class, until they provide a value for their own. If they are instances of a Product class defined in Python, then it is similarly easy. You just define the new property as an attribute in the class (use only immutable types! --> Python language reference). The objects see this "class" property until they define their own value. Otherwise, you may fiddle with "__setstate__" (think about this only, if you already know what "__setstate__" is used for) or use Chris Withers' "update" script (--> mailing list archives). Dieter