[CalendarServer-changes] [6934] CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/ sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:26:16 PST 2011
Revision: 6934
http://trac.macosforge.org/projects/calendarserver/changeset/6934
Author: glyph at apple.com
Date: 2011-02-16 06:26:16 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
refactor dropboxID query
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dalify/txdav/caldav/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:26:04 UTC (rev 6933)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py 2011-02-16 14:26:16 UTC (rev 6934)
@@ -59,6 +59,7 @@
CALENDAR_HOME_TABLE, CALENDAR_HOME_METADATA_TABLE,\
CALENDAR_AND_CALENDAR_BIND, CALENDAR_OBJECT_REVISIONS_AND_BIND_TABLE,\
CALENDAR_OBJECT_AND_BIND_TABLE, schema
+from twext.enterprise.dal.syntax import Select
from txdav.common.icommondatastore import IndexedSearchException
from vobject.icalendar import utc
@@ -119,23 +120,22 @@
returnValue(results)
+
@inlineCallbacks
def calendarObjectWithDropboxID(self, dropboxID):
"""
Implement lookup via queries.
"""
- 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_DROPBOX_ID)s = %%s and
- %(BIND:name)s.%(BIND:column_HOME_RESOURCE_ID)s = %%s
- """ % CALENDAR_OBJECT_AND_BIND_TABLE,
- [dropboxID, self._resourceID,]
- ))
+ co = schema.CALENDAR_OBJECT
+ cb = schema.CALENDAR_BIND
+ rows = (yield Select(
+ [co.PARENT_RESOURCE_ID,
+ co.RESOURCE_ID],
+ From=co.join(cb, co.PARENT_RESOURCE_ID == cb.RESOURCE_ID,
+ 'left outer'),
+ Where=(co.DROPBOX_ID == dropboxID).And(
+ cb.HOME_RESOURCE_ID == self._resourceID)
+ ).on(self._txn))
if rows:
calendarID, objectID = rows[0]
@@ -143,9 +143,9 @@
if calendar:
calendarObject = (yield calendar.objectResourceWithID(objectID))
returnValue(calendarObject)
-
returnValue(None)
+
@inlineCallbacks
def getAllDropboxIDs(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/3f0b3088/attachment.html>
More information about the calendarserver-changes
mailing list