durusmail: durus-users: Using Persistent objects as keys in a BTree
Using Persistent objects as keys in a BTree
2007-05-13
2007-05-13
2007-05-13
Using Persistent objects as keys in a BTree
David K. Hess
2007-05-13
Is it possible to use a Persistent object as a key in a BTree? I'm
having difficulties and suspect the problem has to do with Python's
default object comparison behavior since Persistent doesn't appear to
implement __cmp__. Since Python uses a (dynamic) arbitrary ordering
of in-memory objects for default cmp() behavior it seems to me that
BTree will not work right. I.e. it needs a persistent ordering of the
objects.

If that is the root of the problem, any thoughts on how best to make
this work? Using OID for comparison is the obvious first choice
except there isn't one until after the first commit of the object.
Should I add a serial number to my Persistent subclass and implement
__cmp__ as a comparison of it?

Thanks.

Dave

------
David K. Hess
Verscend Technologies, Inc.
dhess@verscend.com
214-684-5448



reply