[Zope] ZODB & Zope 2.8 ZRDB/TM : "raise" + "except: pass"

Dieter Maurer dieter at handshake.de
Fri Feb 8 16:41:00 EST 2008


Pelletier Vincent wrote at 2008-2-8 10:56 +0100:
>I triggered a bad behaviour in Zope 2.8 Transaction class:
>
>try:
>  <do something>
>  <commit> <- raises conflict error from ZODB's tpc_vote
>except:
>  <cleanup>

Where does this "cleanup" code comes from -- from your application?
>  raise

"try: ... except: ..." are extremely dangerous -- never use them.

If you think you need something like this, always use

   try: ...
   except ConflictError: raise
   except: ....

> ...
>Note that before raising, Transaction.register did
>  adapter.objects.append(obj)

In my Zope 2.8.1, this does not happen -- probably a bug that
has been introduced later.

I would check whether the problematic code is still in the
current Zope version. If so, I would file a bug report.
Otherwise, you may consider an upgrade or a local fix.



-- 
Dieter


More information about the Zope mailing list