[Zope-dev] Renaming a product

Clemens Robbenhaar robbenhaar@espresto.com
Wed, 18 Jun 2003 11:20:31 +0200


Hi Morten,

 > Hi all,
 > 
 > does anyone know how to rename a product, so that instances of the product 
 > stored in ZODB will work (with the new name) after the rename?

 I assume the problem is that the product is named "A" should be
renamed into "B" in such a way that all instances of class
"Product.A.Foo" are of type "Product.B.Foo" afterwards.

 The only way I could think of is to write a migration function
for each class in Product "A", which gets an instance e.g. of class
"Products.A.Foo" and returns an instance of class "Products.B.Foo"
which is suitable to replace the other instance.

 If all Your classes are stored via some standard implementations of
OFS.ObjectManager, it should be easy to recurse from the Zope Application
root and descent into all folders, converting all object of the old
product into those of the new product via the migrtation function.

 The actual work is the transformation of instances of class "A.Foo" to
class "B.Foo"; to be on the safe side one would have to copy over all
attributes manually. If You want to try a fast and dirty solution, You
could try to write the new class into the '__class__' attribute of the
instance of the old class, making it an instance of the new class, but
I do not know it this really works.

Cheers,
Clemens