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

Jim Fulton jim@ZOPE.COM
Wed, 03 Jul 2002 16:31:38 -0400


Jeremy Hylton wrote:
>>>>>>"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.

Sorry, I missread the code. I didn't notice that the ZODB confict error
was subclassing the Transaction one.


> The BTrees nake it even more complicated.  They live under Persistence, so 
> they shouldn't be using a ZODB-specific exception.

Right.

 > Maybe this exception
> class should get moved into Persistence.

What exception?


> 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?

Looking at this again, it looks like ZODB code should always catch the base
ConflictError exception from Transaction.

Jim

-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org