[Zope-dev] transaction as context manager, exception during commit
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 - Zope-Dev@zope.org 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 )
Re: [Zope-dev] [ZODB-Dev] transaction as context manager, exception during commit
On 24 February 2011 10:17, Chris Withers ch...@simplistix.co.uk wrote: 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... Looking at the way ZPublisher handles this, I think you're right. I think you might also need to modify the __exit__ in Attempt, which additionally handles retrying transactions that fail. Laurence ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )
[Zope-dev] Zope Tests: 111 OK, 17 Failed
Summary of messages to the zope-tests list. Period Wed Feb 23 12:00:00 2011 UTC to Thu Feb 24 12:00:00 2011 UTC. There were 128 messages: 8 from Zope Tests, 4 from buildbot at pov.lt, 31 from buildbot at winbot.zope.org, 11 from ccomb at free.fr, 74 from jdriessen at thehealthagency.com. Test failures - Subject: FAILED : Zope Buildbot / zopetoolkit-1.1_win-py2.5 slave-win From: jdriessen at thehealthagency.com Date: Wed Feb 23 10:00:55 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032931.html Subject: FAILED : winbot / ztk_10 py_244_win32 From: buildbot at winbot.zope.org Date: Wed Feb 23 16:06:40 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032992.html Subject: FAILED : ZTK 1.0dev / Python2.4.6 Linux 64bit From: ccomb at free.fr Date: Wed Feb 23 22:12:16 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033014.html Subject: FAILED : ZTK 1.0dev / Python2.6.5 Linux 64bit From: ccomb at free.fr Date: Wed Feb 23 22:13:00 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033015.html Subject: FAILED : ZTK 1.0dev / Python2.5.5 Linux 64bit From: ccomb at free.fr Date: Wed Feb 23 22:13:11 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033016.html Subject: FAILED : winbot / z3c.form_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 22:29:48 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033018.html Subject: FAILED : winbot / z3c.rml_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:05:00 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033020.html Subject: FAILED : winbot / z3c.template_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:13:48 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033021.html Subject: FAILED : winbot / z3c.layer.ready2go_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:19:05 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033022.html Subject: FAILED : winbot / z3c.formui_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:20:24 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033023.html Subject: FAILED : winbot / z3c.tabular_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:22:34 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033024.html Subject: FAILED : winbot / z3c.contents_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:23:27 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033025.html Subject: FAILED : winbot / z3c.ptcompat_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:40:29 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033026.html Subject: FAILED : winbot / z3c.pdftemplate_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:44:18 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033027.html Subject: FAILED : winbot / z3c.coverage_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:45:39 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033028.html Subject: FAILED : winbot / z3c.macro_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:46:23 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033029.html Subject: FAILED : winbot / z3c.pagelet_py_265_32 From: buildbot at winbot.zope.org Date: Wed Feb 23 23:50:34 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033030.html Tests passed OK --- Subject: OK : Zope Buildbot / zope2.12-py2.6 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:02:33 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032913.html Subject: OK : Zope Buildbot / zope2.13-py2.6 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:03:56 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032914.html Subject: OK : Zope Buildbot / zope2.13-py2.7 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:05:21 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032915.html Subject: OK : Zope Buildbot / zope2.14-py2.6 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:06:48 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032916.html Subject: OK : Zope Buildbot / zope2.14-py2.7 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:08:10 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032917.html Subject: OK : Zope Buildbot / zope2.13_win-py2.6 slave-win From: jdriessen at thehealthagency.com Date: Wed Feb 23 09:13:03 EST 2011 URL: http://mail.zope.org/pipermail/zope-tests/2011-February/032918.html Subject: OK : Zope Buildbot / zopetoolkit-1.0-py2.4 slave-ubuntu64 From: jdriessen at thehealthagency.com Date: Wed
Re: [Zope-dev] [ZODB-Dev] transaction as context manager, exception during commit
On 24/02/2011 11:38, Laurence Rowe wrote: 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... Looking at the way ZPublisher handles this, I think you're right. Cool, I'll wait for Jim's verdict (and some time to implement it ;-)) before diving in... I think you might also need to modify the __exit__ in Attempt, which additionally handles retrying transactions that fail. Yeah, I see a bug relating to this was reported yesterday: https://bugs.launchpad.net/bugs/724332 I know it's a different problem, but sounds like the code for attempt needs some love... cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )