[CalendarServer-changes] [10253] CalendarServer/branches/users/glyph/queue-locking-and-timing
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 4 16:39:13 PST 2013
Revision: 10253
http://trac.calendarserver.org//changeset/10253
Author: glyph at apple.com
Date: 2013-01-04 16:39:13 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Abort the transaction automatically if a pre-commit hook fails.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py
CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/test/test_adbapi2.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/queue-locking-and-timing/
Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py 2013-01-05 00:39:11 UTC (rev 10252)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/adbapi2.py 2013-01-05 00:39:13 UTC (rev 10253)
@@ -525,9 +525,12 @@
"""
Run pre-hooks, commit, the real DB commit, and then post-hooks.
"""
- return self._preCommit.runHooks().addCallback(
- lambda ignored: doCommit().addCallback(self._commit.runHooks)
- )
+ pre = self._preCommit.runHooks()
+ def ok(ignored):
+ return doCommit().addCallback(self._commit.runHooks)
+ def failed(why):
+ return self.abort().addCallback(lambda ignored: why)
+ return pre.addCallbacks(ok, failed)
def preCommit(self, operation):
Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/test/test_adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/test/test_adbapi2.py 2013-01-05 00:39:11 UTC (rev 10252)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/test/test_adbapi2.py 2013-01-05 00:39:13 UTC (rev 10253)
@@ -1164,8 +1164,8 @@
result = self.resultOf(txn.commit())
self.flushHolders()
self.assertResultList(result, Failure(exc()))
+ self.assertEquals(test.committed, False)
self.assertEquals(test.aborted, True)
- self.assertEquals(test.committed, False)
def failer():
return fail(ZeroDivisionError())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/76cc6b6c/attachment.html>
More information about the calendarserver-changes
mailing list