[ZODB-Dev] Weird KeyError with OOBTree

Pedro Ferreira jose.pedro.ferreira at cern.ch
Mon Aug 16 08:04:45 EDT 2010


> PyObject_Compare to compare different keys. Persistent doesn't
> implement any special compare function and falls back to the standard
> hash algorithm for an object. This happens to be its memory address.
> The memory address obviously changes over time and the same address
> gets reused for different objects.
>    

Makes total sense... actually:

http://www.zodb.org/documentation/guide/modules.html#total-ordering-and-persistence

Seems to indicate that.


Actually, i believe that what mislead me was:

" Prior to this change, it was not safe to use Persistent objects as 
keys in a BTree." ( 
http://docs.zope.org/zope3/Code/ZODB/ConflictResolution.txt/index.html)

> I think implementing a stable hash function for your type could make
> this work though.
>
>    

 From what I read, ZODB doesn't use hash functions, relying on __cmp__ 
instead. So, I guess I should make my class non-persistent and implement 
a __cmp__ function for it...

Thanks a lot!

Pedro

-- 
José Pedro Ferreira

Indico Team

IT-UDS-AVC

513-R-0042
CERN, Geneva, Switzerland

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


More information about the ZODB-Dev mailing list