[Zope] Changing class of objects in the ZODB

Doyon, Jean-Francois Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Mon Jun 12 12:03:31 EDT 2006


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 at zope.org [mailto:zope-bounces at zope.org] On Behalf Of
Miles Waller
Sent: June 12, 2006 11:58 AM
To: zope at 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 at 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 )


More information about the Zope mailing list