[ZODB-Dev] Looking for a specific object...

Shane Hathaway shane@zope.com
Wed, 06 Mar 2002 23:44:14 -0500


Greg Ward wrote:
> Right, yes, the "I renamed my class/module" problem.

FYI there is now some working code that can deal with this.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/zodbex/zodbex/ChangeModules/change_modules.py?rev=1.3&content-type=text/vnd.viewcvs-markup

It can be installed as a Zope external method or used in a pure ZODB 
application.  You can use the default class translator like this:

changeClassModules(some_zodb_object, 'Products.PythonMethod',
                    'Products.PythonScript')

This code could be added to ZODB/ExportImport.py, where IMHO it would 
actually fit right in.  But I haven't yet figured out how to expose the 
functionality.  It's not something you'd use very often at all, but 
would be helpful for refactoring.

Another idea I've toyed with is that the ZODB might hold a central 
registry of class names.  Pickled instances would contain, rather than a 
(module, name) pair, an integer that refers to a class name in the 
registry.  After changing class names you'd only have to go to one 
place, and your database would even be a little smaller.

If the class registry got corrupted in any way, though, you'd be toast. :-)

Shane