[CalendarServer-changes] [6952] CalendarServer/branches/users/glyph/dalify/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:29:46 PST 2011
Revision: 6952
http://trac.macosforge.org/projects/calendarserver/changeset/6952
Author: glyph at apple.com
Date: 2011-02-16 06:29:46 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify objectResourcesWithUID
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py
CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py
CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py
Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py 2011-02-16 14:29:33 UTC (rev 6951)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py 2011-02-16 14:29:46 UTC (rev 6952)
@@ -82,6 +82,7 @@
_bindSchema = schema.CALENDAR_BIND
_homeMetaDataSchema = schema.CALENDAR_HOME_METADATA
_revisionsSchema = schema.CALENDAR_OBJECT_REVISIONS
+ _objectSchema = schema.CALENDAR_OBJECT
# string mappings (old, removing)
_homeTable = CALENDAR_HOME_TABLE
Modified: CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py 2011-02-16 14:29:33 UTC (rev 6951)
+++ CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py 2011-02-16 14:29:46 UTC (rev 6952)
@@ -69,6 +69,7 @@
_bindSchema = schema.ADDRESSBOOK_BIND
_homeMetaDataSchema = schema.ADDRESSBOOK_HOME_METADATA
_revisionsSchema = schema.ADDRESSBOOK_OBJECT_REVISIONS
+ _objectSchema = schema.ADDRESSBOOK_OBJECT
# string mappings (old, removing)
_homeTable = ADDRESSBOOK_HOME_TABLE
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:29:33 UTC (rev 6951)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:29:46 UTC (rev 6952)
@@ -788,36 +788,36 @@
return None
+ @classproperty
+ def _resourceByUIDQuery(cls):
+ obj = cls._objectSchema
+ bind = cls._bindSchema
+ return Select([obj.PARENT_RESOURCE_ID, obj.RESOURCE_ID],
+ From=obj.join(bind, obj.PARENT_RESOURCE_ID ==
+ bind.RESOURCE_ID),
+ Where=(obj.UID == Parameter("uid")).And(
+ bind.HOME_RESOURCE_ID == Parameter("resourceID")))
+
+
@inlineCallbacks
def objectResourcesWithUID(self, uid, ignore_children=()):
"""
- Return all child object resources with the specified UID, ignoring any in the
- named child collections. The file implementation just iterates all child collections.
+ Return all child object resources with the specified UID, ignoring any
+ in the named child collections.
"""
-
results = []
- rows = (yield self._txn.execSQL("""
- select %(OBJECT:name)s.%(OBJECT:column_PARENT_RESOURCE_ID)s, %(OBJECT:column_RESOURCE_ID)s
- from %(OBJECT:name)s
- left outer join %(BIND:name)s on (
- %(OBJECT:name)s.%(OBJECT:column_PARENT_RESOURCE_ID)s = %(BIND:name)s.%(BIND:column_RESOURCE_ID)s
- )
- where
- %(OBJECT:column_UID)s = %%s and
- %(BIND:name)s.%(BIND:column_HOME_RESOURCE_ID)s = %%s
- """ % self._objectBindTable,
- [uid, self._resourceID,]
- ))
-
+ rows = (yield self._resourceByUIDQuery.on(self._txn, uid=uid,
+ resourceID=self._resourceID))
if rows:
for childID, objectID in rows:
child = (yield self.childWithID(childID))
if child and child.name() not in ignore_children:
objectResource = (yield child.objectResourceWithID(objectID))
results.append(objectResource)
-
+
returnValue(results)
+
@inlineCallbacks
def quotaUsedBytes(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/dc8c3b79/attachment-0001.html>
More information about the calendarserver-changes
mailing list