[CalendarServer-changes] [6977] 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:41 PST 2011
Revision: 6977
http://trac.macosforge.org/projects/calendarserver/changeset/6977
Author: glyph at apple.com
Date: 2011-02-16 06:34:41 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify resourceUIDForName
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:30 UTC (rev 6976)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:34:41 UTC (rev 6977)
@@ -1488,8 +1488,7 @@
"""
obj = cls._objectSchema
return Select(
- [obj.RESOURCE_NAME],
- From=obj,
+ [obj.RESOURCE_NAME], From=obj,
Where=(obj.UID == Parameter("uid")
).And(obj.PARENT_RESOURCE_ID == Parameter("resourceID")))
@@ -1510,6 +1509,19 @@
returnValue(None)
+ @classproperty
+ def _resourceUIDForNameQuery(cls):
+ """
+ DAL query to retrieve the UID for an object resource based on its
+ resource name column.
+ """
+ obj = cls._objectSchema
+ return Select(
+ [obj.UID], From=obj,
+ Where=(obj.UID == Parameter("name")
+ ).And(obj.PARENT_RESOURCE_ID == Parameter("resourceID")))
+
+
@inlineCallbacks
def resourceUIDForName(self, name):
try:
@@ -1517,20 +1529,15 @@
returnValue(resource.uid() if resource else None)
except KeyError:
pass
-
- rows = yield self._txn.execSQL("""
- select %(column_UID)s
- from %(name)s
- where %(column_RESOURCE_NAME)s = %%s and %(column_PARENT_RESOURCE_ID)s = %%s
- """ % self._objectTable,
- [name, self._resourceID]
- )
+ rows = yield self._resourceUIDForNameQuery.on(
+ self._txn, name=name, resourceID=self._resourceID)
if rows:
returnValue(rows[0][0])
else:
self._objects[name] = None
returnValue(None)
+
@inlineCallbacks
def createObjectResourceWithName(self, name, component, metadata=None):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/74057242/attachment.html>
More information about the calendarserver-changes
mailing list