[CalendarServer-changes] [13200] CalendarServer/trunk/txdav/common/datastore/sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 8 12:50:10 PDT 2014
Revision: 13200
http://trac.calendarserver.org//changeset/13200
Author: sagen at apple.com
Date: 2014-04-08 12:50:09 -0700 (Tue, 08 Apr 2014)
Log Message:
-----------
Use subtransaction mechanism
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/sql.py
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2014-04-08 19:42:44 UTC (rev 13199)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2014-04-08 19:50:09 UTC (rev 13200)
@@ -1468,20 +1468,22 @@
read-only access
@type readWrite: C{boolean}
"""
- savepoint = SavepointAction("addDelegate")
- yield savepoint.acquire(self)
- try:
- yield self._addDelegateQuery.on(
- self,
+
+ def _addDelegate(subtxn):
+ return self._addDelegateQuery.on(
+ subtxn,
delegator=delegator.encode("utf-8"),
delegate=delegate.encode("utf-8"),
readWrite=1 if readWrite else 0
)
- except Exception:
- # Row already exists
- yield savepoint.rollback(self)
+ try:
+ yield self.subtransaction(_addDelegate, retries=0, failureOK=True)
+ except AllRetriesFailed:
+ pass
+
+
@inlineCallbacks
def addDelegateGroup(self, delegator, delegateGroupID, readWrite,
isExternal=False):
@@ -1497,21 +1499,23 @@
read-only access
@type readWrite: C{boolean}
"""
- savepoint = SavepointAction("addDelegateGroup")
- yield savepoint.acquire(self)
- try:
- yield self._addDelegateGroupQuery.on(
- self,
+
+ def _addDelegateGroup(subtxn):
+ return self._addDelegateGroupQuery.on(
+ subtxn,
delegator=delegator.encode("utf-8"),
groupID=delegateGroupID,
readWrite=1 if readWrite else 0,
isExternal=1 if isExternal else 0
)
- except Exception:
- # Row already exists
- yield savepoint.rollback(self)
+ try:
+ yield self.subtransaction(_addDelegateGroup, retries=0, failureOK=True)
+ except AllRetriesFailed:
+ pass
+
+
def removeDelegate(self, delegator, delegate, readWrite):
"""
Removes a row from the DELEGATES table. The delegate should not be a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140408/0168b12d/attachment.html>
More information about the calendarserver-changes
mailing list