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

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:34:30 PST 2011


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

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:17 UTC (rev 6975)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:34:30 UTC (rev 6976)
@@ -1480,6 +1480,20 @@
         returnValue(objectResource)
 
 
+    @classproperty
+    def _resourceNameForUIDQuery(cls):
+        """
+        DAL query to retrieve the resource name for an object resource based on
+        its UID column.
+        """
+        obj = cls._objectSchema
+        return Select(
+            [obj.RESOURCE_NAME],
+            From=obj,
+            Where=(obj.UID == Parameter("uid")
+                  ).And(obj.PARENT_RESOURCE_ID == Parameter("resourceID")))
+
+
     @inlineCallbacks
     def resourceNameForUID(self, uid):
         try:
@@ -1487,20 +1501,15 @@
             returnValue(resource.name() if resource else None)
         except KeyError:
             pass
-
-        rows = yield self._txn.execSQL("""
-            select %(column_RESOURCE_NAME)s
-            from %(name)s
-            where %(column_UID)s = %%s and %(column_PARENT_RESOURCE_ID)s = %%s
-            """ % self._objectTable,
-            [uid, self._resourceID]
-        )
+        rows = yield self._resourceNameForUIDQuery.on(
+            self._txn, uid=uid, resourceID=self._resourceID)
         if rows:
             returnValue(rows[0][0])
         else:
             self._objects[uid] = None
             returnValue(None)
 
+
     @inlineCallbacks
     def resourceUIDForName(self, name):
         try:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/25d0f7c5/attachment.html>


More information about the calendarserver-changes mailing list