transaction as context manager, exception during commit

Chris Withers <[email protected]>
Newsgroups gmane.comp.web.zope.devel,gmane.comp.web.zope.zodb
Message-ID <[email protected]>
Hi Jim,

The current __exit__ for transaction managers looks like this:

     def __exit__(self, t, v, tb):
         if v is None:
             self.commit()
         else:
             self.abort()

..which means that if you're using the transaction package as a context 
manager and, say, a relational database integrity constraint is 
violated, then you're left with a hosed transaction that still needs 
aborting.

How would you feel about the above changing to:

     def __exit__(self, t, v, tb):
         if v is None:
             try:
                 self.commit()
             except:
                 self.abort()
                 raise
         else:
             self.abort()

If this is okay, I'll be happy to write the tests and make the changes 
provided someone does a release when I have...

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.