[CalendarServer-changes] [6979] 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:04 PST 2011


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

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:34:52 UTC (rev 6978)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:35:04 UTC (rev 6979)
@@ -1561,20 +1561,27 @@
         returnValue(objectResource)
 
 
+    @classproperty
+    def _removeObjectResourceByNameQuery(cls):
+        """
+        DAL query to remove an object resource from this collection by name,
+        returning the UID of the resource it deleted..
+        """
+        obj = cls._objectSchema
+        return Delete(From=obj,
+                      Where=(obj.RESOURCE_NAME == Parameter("name")).And(
+                          obj.PARENT_RESOURCE_ID == Parameter("resourceID")),
+                     Return=obj.UID)
+
+
     @inlineCallbacks
     def removeObjectResourceWithName(self, name):
-
-        uid = (yield self._txn.execSQL(
-            "delete from %(name)s "
-            "where %(column_RESOURCE_NAME)s = %%s and %(column_PARENT_RESOURCE_ID)s = %%s "
-            "returning %(column_UID)s" % self._objectTable,
-            [name, self._resourceID],
-            raiseOnZeroRowCount=lambda:NoSuchObjectResourceError()
-        ))[0][0]
+        uid = (yield self._removeObjectResourceByNameQuery.on(
+            self._txn, NoSuchObjectResourceError,
+            name=name, resourceID=self._resourceID))[0][0]
         self._objects.pop(name, None)
         self._objects.pop(uid, None)
         yield self._deleteRevision(name)
-
         self.notifyChanged()
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/fd23cc59/attachment.html>


More information about the calendarserver-changes mailing list