[Zope3-Users] Re: Evolution of ZoDB after changing python modules structure (moving content classes to another module)

Alek Kowalczyk thealx at poczta.onet.pl
Fri Jun 8 06:44:38 EDT 2007


Alek Kowalczyk <thealx at ...> writes:

> 
> Hi,
> I moved my content class from mypackage.mymodule.MyContentClass into
> mypackage.mysubpackage.mymodule.MyContentClass.
> But when started Zope and went to visit an object I have previously created (of
> MyContentClass), I get:
> ComponentLookupError: ((<persistent broken mypackage.mymodule.MyContentClass
> instance '\x00\x00\x00\x00\x00\x00\x02q'>,
> <zope.publisher.browser.BrowserRequest instance
>
URL=http://localhost:8080/++skin++MySkin/SomeFolder/SomeFolder/ObjectOfMyContentClass/
<at>  <at> index.html>),
> <InterfaceClass zope.interface.Interface>, 'index.html')
> 
> I'm already familiar with generations - I've done two up to now. I guess I
> should somehow evolve the ZoDB to 'rename' paths.to.RelocatedClasses.
> 
> But I don't know how to do that?
> 

I found a quite well working solution on
http://mail.zope.org/pipermail/zodb-dev/2006-September/010382.html

There was only one issue: this solution assumes that we have given a DB, while
Zope evolve method receives already open connection. Unfortunately classFactory
from DB is cached in Connection's private fields in constructor.
Because of that I could not assign my custom 'renaming' class factory using:

def evolve(context): #won't work!
    context.connection.db().classFactory = myClassFactory 

Instead I had to do some dirty private fields substitution in Connection's
ObjectReader:

def evolve(context): #this works nice
    context.connection._reader._factory = myClassFactory





More information about the Zope3-users mailing list