[CalendarServer-changes] [6981] CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/ sql.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:35:27 PST 2011


Revision: 6981
          http://trac.macosforge.org/projects/calendarserver/changeset/6981
Author:   glyph at apple.com
Date:     2011-02-16 06:35:27 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify removeObjectResourceWithUID

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:35:15 UTC (rev 6980)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:35:27 UTC (rev 6981)
@@ -1565,7 +1565,7 @@
     def _removeObjectResourceByNameQuery(cls):
         """
         DAL query to remove an object resource from this collection by name,
-        returning the UID of the resource it deleted..
+        returning the UID of the resource it deleted.
         """
         obj = cls._objectSchema
         return Delete(From=obj,
@@ -1585,15 +1585,24 @@
         self.notifyChanged()
 
 
+    @classproperty
+    def _removeObjectResourceByUIDQuery(cls):
+        """
+        DAL query to remove an object resource from this collection by UID,
+        returning the name of the resource it deleted.
+        """
+        obj = cls._objectSchema
+        return Delete(From=obj,
+                      Where=(obj.UID == Parameter("uid")).And(
+                          obj.PARENT_RESOURCE_ID == Parameter("resourceID")),
+                     Return=obj.RESOURCE_NAME)
+
+
     @inlineCallbacks
     def removeObjectResourceWithUID(self, uid):
-
-        name = (yield self._txn.execSQL(
-            "delete from %(name)s "
-            "where %(column_UID)s = %%s and %(column_PARENT_RESOURCE_ID)s = %%s "
-            "returning %(column_RESOURCE_NAME)s" % self._objectTable,
-            [uid, self._resourceID],
-            raiseOnZeroRowCount=lambda:NoSuchObjectResourceError()
+        name = (yield self._removeObjectResourceByUIDQuery.on(
+            self._txn, NoSuchObjectResourceError,
+            uid=uid, resourceID=self._resourceID
         ))[0][0]
         self._objects.pop(name, None)
         self._objects.pop(uid, None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/988663ba/attachment-0001.html>


More information about the calendarserver-changes mailing list