[ZODB-Dev] OOBTree: Persistent Objects as keys
Thomas Guettler
zopestoller@thomas-guettler.de
Tue, 05 Feb 2002 10:46:52 +0100
I have a strange problem with persistent objects as keys
in a OOBTree. It reduced the problem to this:
def test_btree(self):
for key in self._tree.keys():
value=self._tree.get(key, None)
if value==None:
raise Exception, "Very strange: key not in tree.keys()"
It works if I store integers as keys, but fails if I use my class with
inherits
from Zope Folder. It only happens if the objects of my class are attached
to the zope tree. If they are not attached to the zope tree (which means
garbage
collection would delete them as soon as the request finished) it works.
The __hash__ function of my class:
_hash=0
def __hash__(self):
if self._hash==0: self._hash=randrange(0, 65536)
return self._hash
It is very strange, because if I retry it is sometimes successful!
thomas