[Zope-dev] transaction.doom() and ZPublisher

Paul Winkler slinkp at gmail.com
Thu Jul 10 00:12:06 EDT 2008


Hi,

I noticed that Zope 2.11 includes a recent version of the transaction
module including the transaction.doom() method.  But I don't see any
check for it in ZPublisher.

So, if any code calls transaction.doom(), the publisher will raise a
user-visible exception when it tries to call commit().  This seems
less than useful :-)

In the discussion I've seen of this method, eg.
https://bugs.launchpad.net/zope3/+bug/98382 and
http://markmail.org/message/3yshpmltvhevnrff it sounds like other
people share my expectation... namely, that the developer should not
have to do anything special after calling transaction.doom(); the
transaction is not committed, and the user won't see an exception.

Is that the concensus? If so, there's an easy solution -
apply something like the attached patch.

Anybody disagree?


-- 

Paul Winkler
http://www.slinkp.com
-------------- next part --------------
--- Zope2/App/startup.py~	2008-06-14 02:50:23.000000000 -0400
+++ Zope2/App/startup.py	2008-07-10 00:08:02.000000000 -0400
@@ -267,7 +267,8 @@
         transaction.begin()
 
     def commit(self):
-        transaction.commit()
+        if not transaction.isDoomed():
+            transaction.commit()
 
     def abort(self):
         transaction.abort()
--- ZPublisher/Publish.py~	2008-06-14 02:50:48.000000000 -0400
+++ ZPublisher/Publish.py	2008-07-10 00:08:08.000000000 -0400
@@ -314,7 +314,8 @@
     def begin(self):
         transaction.begin()
     def commit(self):
-        transaction.commit()
+        if not transaction.get().isDoomed():
+            transaction.commit()
     def abort(self):
         transaction.abort()
     def recordMetaData(self, object, request):
--- ZPublisher/WSGIPublisher.py~	2008-06-14 02:50:48.000000000 -0400
+++ ZPublisher/WSGIPublisher.py	2008-07-09 23:59:57.000000000 -0400
@@ -401,7 +401,8 @@
     def begin(self):
         transaction.begin()
     def commit(self):
-        transaction.commit()
+        if not transaction.get().isDoomed():
+            transaction.commit()
     def abort(self):
         transaction.abort()
     def recordMetaData(self, object, request):


More information about the Zope-Dev mailing list