[CalendarServer-changes] [8754] CalendarServer/trunk/txdav/common/datastore/sql_legacy.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 22 07:13:38 PST 2012


Revision: 8754
          http://trac.macosforge.org/projects/calendarserver/changeset/8754
Author:   cdaboo at apple.com
Date:     2012-02-22 07:13:37 -0800 (Wed, 22 Feb 2012)
Log Message:
-----------
Re-roder query so that BIND constraints apply before the INVITE query.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/common/datastore/sql_legacy.py

Modified: CalendarServer/trunk/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2012-02-22 15:10:47 UTC (rev 8753)
+++ CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2012-02-22 15:13:37 UTC (rev 8754)
@@ -347,6 +347,10 @@
         shareeHome = yield self._getHomeWithUID(record.principalUID)
         rows = yield self._idsForInviteUID.on(self._txn,
                                               inviteuid=record.inviteuid)
+        
+        # FIXME: Do the BIND table query before the INVITE table query because BIND currently has proper
+        # constraints in place, whereas INVITE does not. Really we need to do this in a sub-transaction so
+        # we can roll back if any one query fails.
         if rows:
             [[resourceID, homeResourceID]] = rows
             yield self._updateBindQuery.on(
@@ -358,12 +362,6 @@
                 self._txn, name=record.name, uid=record.inviteuid
             )
         else:
-            yield self._insertInviteQuery.on(
-                self._txn, uid=record.inviteuid, name=record.name,
-                homeID=shareeHome._resourceID,
-                resourceID=self._collection._resourceID,
-                recipient=record.userid
-            )
             yield self._insertBindQuery.on(
                 self._txn,
                 homeID=shareeHome._resourceID,
@@ -372,6 +370,12 @@
                 status=bindStatus,
                 message=record.summary
             )
+            yield self._insertInviteQuery.on(
+                self._txn, uid=record.inviteuid, name=record.name,
+                homeID=shareeHome._resourceID,
+                resourceID=self._collection._resourceID,
+                recipient=record.userid
+            )
         
         # Must send notification to ensure cache invalidation occurs
         self._collection.notifyChanged()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120222/27690591/attachment.html>


More information about the calendarserver-changes mailing list