[ZODB-Dev] ZODB4 - Why two inheritance branches for ConflictError ?

Jeremy Hylton jeremy@zope.com
Wed, 3 Jul 2002 16:02:10 -0400


>>>>> "JF" == Jim Fulton <jim@zope.com> writes:

  JF> Ury Marshak wrote:
  >> ZODB4 - Why two inheritance branches for ConflictError ?
  >>
  >> While digging around in ZODB4 I accidently discovered that the
  >> class BTreesConflictError (in Persistence/BTrees/Exception.py)
  >> inherits from Transaction.Exceptions.ConflictError . What happens
  >> is that the code (including the ZODB itself) using the 'from
  >> ZODB.POSException import ConflictError' line is unable to catch
  >> the Btrees exceptions, cause ZODB.POSException.ConflictError is
  >> also inheriting from Transaction.Exceptions.ConflictError. Is
  >> this the new inheritance model (meaning, do I have to catch
  >> exceptions by using 'except
  >> Transaction.Exceptions.ConflictError:' now?

  JF> This is clearly a bug. When the transaction frameworks were
  JF> split off from ZODB, the relevent exceptions should have gone
  JF> with them. We should move the transaction errors to
  JF> Transaction.Exceptions.

  JF> Anybody with commit access wanna do this? :)

It's not clear to me what the bug is :-).

It makes sense for user-code to catch Transaction.Exceptions.ConflictError.

ZODB subclasses this exception because it adds ZODB-specific data like
the name of the class and the serial numbers involved.  I don't think
Transaction has any business knowing about these.

The BTrees nake it even more complicated.  They live under Persistence, so 
they shouldn't be using a ZODB-specific exception. Maybe this exception 
class should get moved into Persistence.

The distinction between a persistence exception vs. a transaction
exception is very fuzzy to me.  With ConflictError, a problem in the
persistence machinery prevents the transaction from completing.  What
package should this error belong to?

Jeremy