[ZODB-Dev] Broken instances after refactoring in ZODB

Wichert Akkerman wichert at wiggy.net
Sat Oct 4 11:36:26 EDT 2008


Adam wrote:
> On Fri, 2008-10-03 at 14:24 -0600, Shane Hathaway wrote:
>    
>> Marius Gedminas wrote:
>>      
>>>    1. create modules in their old locations that import all the classes
>>>       from the new locations (and do nothing else).
>>>    2. write a script that opens the DB, iterates over all persistent
>>>       objects in it, touches every single one of them (obj._p_activate()
>>>       followed by obj._p_changed = True) and commits the transaction.
>>>        
>> Marius said it correctly, but I'd like to emphasize that it's not enough
>> to touch just the objects whose class changed, since persistent
>> references encode the module and class name.  It's best to just touch
>> everything.  You will have to use multiple transactions to touch
>> everything in a large database.
>>      
>
> Thanks for that, guys, I've not used a mailing list like this before so
> unsure how to respond.
>
> If ZODB stores the Package.Module.Class name in the pickle would it be
> possible for me to simply rename them in the binary file?
>
> My confusion here is that I've globally imported everything from the
> packages into the current namespace of my main module. ZODB shouldn't be
> aware I've moved the modules since for all intents and purposes to
> Python, they are still there.
>    

It doesn't matter where you import it from or to - python uses the 
location of the actual implementation and ZODB uses that. If you move 
your implementation to another place you have to either update all 
objects in the ZODB or add module aliases.

Wichert.

-- 
Wichert Akkerman<wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                  It is hard to make things simple.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zodb-dev/attachments/20081004/b1fa9eac/attachment.html 


More information about the ZODB-Dev mailing list