[Zope3-Users] Re: Evolution of ZoDB after changing python modules
structure (moving content classes to another module)
Aleksander Kowalczyk
thealx at poczta.onet.pl
Tue Jun 12 08:51:13 EDT 2007
On 6/12/07, Rupert Redington <rupert at neontribe.co.uk> wrote:
>
> Aleksander Kowalczyk wrote:
> > On 6/8/07, Alek Kowalczyk <thealx at poczta.onet.pl> wrote:
> >>
> >> 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
> >>
> > I found a quite well working solution on
> >> http://mail.zope.org/pipermail/zodb-dev/2006-September/010382.html
> >> [...]
> > I shouldn't announce success too early. The solution works but only
> during
> > first Zope run (i.e just after evolving the schema).
> > Although classFactory returns proper class during evolve, the new class
> > name
> > is not saved in ZoDB, so after next unghosting object get old class
> names
> > again.
> >
> > Here is my evolve script. I really don't know what more should I do to
> make
> > Zope/ZoDB write the new class name in ZoDB. Can someone help me a bit...
> :)
> >
>
> Somebody correct me if I'm wrong
> I imagine you'd need to commit the transaction manually:
>
>
> def evolve(context):
> #dirty hack to substitute classFactory
> context.connection._reader._factory = convertingClassFactory
> root = context.connection.root().get(ZopePublication.root_name, None)
> for object in findObjectsMatching(root, lambda x: True):
> if hasattr(object, '_p_activate'):
> object._p_activate()
> object._p_changed = True
> import transaction
> transaction.commit()
>
>
> Hope that helps,
>
> Rupert
>
Yes, I've tried this already - it doesn't work too :(
I have removed this because I believe Zope.generations do the commit for me
after calling my evolve function.
Thanks!
Alek Kowalczyk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20070612/e79c8f0c/attachment.htm
More information about the Zope3-users
mailing list