[ZODB-Dev] BTree corrupted after conflict resolution

Tim Peters tim at zope.com
Mon Mar 8 11:23:18 EST 2004


[Jeremy Hylton]
> It is by design that object identity is preserved by
> PersistentReference objects.  It doesn't sound too hard to add an
> __cmp__(), but I'm not sure how useful it is.

Me neither.

> Is it possible to define an __cmp__() that raises an exception and
> then add __ne__ and __eq__ methods that don't raise an exception?

That's what, e.g., the Python 2.3 sets.py does for sets.Set comparisions:

>>> from sets import Set
>>> s1 = Set([1])
>>> s2 = Set([2])
>>> s1 == s2
False
>>> cmp(s1, s2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\PYTHON23\Lib\sets.py", line 132, in __cmp__
    raise TypeError, "can't compare sets using cmp()"
TypeError: can't compare sets using cmp()
>>>


See later email in this thread, though:  bucket merge also uses __cmp__ for
*value* (not just key) comparison today, and that code is buggy (ignores the
possibility of exceptions).  If we fixed the bugs, I'm not sure we'd want to
raise an exception just because IOBTree sometree[42] was set to different
persistent objects by two transactions.  User-defined conflict resolution
code that happens to compare persistent object(stub)s would also start
raising exceptions.  Maybe that's OK, though (new exceptions would get
logged, but transformed into ConflictError).  Don't know.




More information about the ZODB-Dev mailing list