RE: [Zope] Changing class of objects in the ZODB
Assuming you're not changing attribute values, but *just* the class, I've had success with doing an XML export, a find/replace of the class name, and a re-import. The XML is fairly readable, you can just look for example for "Products.MyProduct.OldClass" and replace it with "Products.MyProduct.NewClass". J.F. -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Miles Waller Sent: June 12, 2006 11:58 AM To: zope@zope.org Subject: [Zope] Changing class of objects in the ZODB Hi, Does anyone have a good approach to changing the class of an object already stored in the ZODB? A site is using classes defined and customised in a product on the filesystem, and I want to split the product into two to separate the unmodified vanilla product, and customisations. I found a script from shane when I googled which purported to do this, but I did not understand exactly what it did and so am a bit nervous of using it. Also, it appeared to do it all in one transaction, which would not be practical for this site (too many objects). I had originally been envisaging doing something in __getstate__ for these objects, so when they were retrieved, they were updated and marked as having been changed so they would be committed at the end of the transaction. But I don't really know exactly what! I don't think it will work to use module_aliases because there will still be a class that can be imported from the original location. Any help much appreciated, Miles _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
To confirm, I *just* want to change the class - attribute values, name and state information can remain exactly the same. XML import/export is a good approach which I need to think about a bit more. On the face of it, the data.fs is well over 1Gb in size after packing, and so is likely to create some issues in itself, but there may be ways to make this more straightforward. Doyon, Jean-Francois wrote:
Assuming you're not changing attribute values, but *just* the class, I've had success with doing an XML export, a find/replace of the class name, and a re-import.
The XML is fairly readable, you can just look for example for "Products.MyProduct.OldClass" and replace it with "Products.MyProduct.NewClass".
J.F.
participants (2)
-
Doyon, Jean-Francois -
Miles Waller