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? Thanks, Morten W. Petersen -- Technologies: Zope, Linux, Python, HTML, CSS, PHP Homepage: http://www.nidelven-it.no Phone number: (+47) 45 44 00 69
Morten W. Petersen wrote:
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?
Your question does not compute ... What part of the product do you want to rename? The meta_type? The title? The Id? regards Max M
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
Clemens Robbenhaar wrote:
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.
Somebody correct me please, if I'm wrong, but 1. tinkering with __class__ is the only way to do this. 2. you can not tinker with __class__ of an ExtensionClass, i.e. all Persistent objects. So, it is not doable, IIRC. Phil
participants (4)
-
Clemens Robbenhaar -
Max M -
Morten W. Petersen -
Philipp von Weitershausen