[ZODB-Dev] KeyError on OIBTree after export import

Bernd Dorn bernd.dorn at lovelysystems.com
Wed Mar 14 15:19:07 EDT 2007


On 14.03.2007, at 19:16, Dieter Maurer wrote:

> Bernd Dorn wrote at 2007-3-14 11:39 +0100:
>> ...
>> but after the import in the .ids attribute of the util (which is an
>> OIBtree) raises a KeyError for an existing key
>>
>> so if i do
>>
>>>>> key in sorted(self.ids)
>> True
>>>>> self.ids[key]
>> KeyError ...
>
> I can explain to you why you may get different results (also I cannot
> tell you why you have the inconsistency).
>
> An XYBTree uses two different structures for the enumeration of
> its elements (e.g. "iter(tree)") and the random access (e.g. tree 
> [key]).
>
> The tree root has a link to its left most leaf and all
> leaves are linked together. These links use used for enumeration.
>
> Random access uses the internal nodes to find the leaf that may
> contain the key and then access it there.
>
>
> What you see means that the leaf links are correct but some
> internal node is broken (contains a stale reference).
>

hi dieter

thx for the answer ... but now i found out why this happens, it is a  
KeyReferenceToPersistence problem in zope, so this is the wrong list :-(

but just for the records:

keyreference uses its object's oid and database name to build its  
hash from, so when you export and reimport objects referenced, the  
hashes are wrong, because the objects have new oids

i will fix those hashes at import time in my package, where the old  
and the new oid are available

thx, bernd

>
>
> -- 
> Dieter



More information about the ZODB-Dev mailing list