[CalendarServer-changes] [6948] CalendarServer/branches/users/glyph/dalify/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:28:56 PST 2011
Revision: 6948
http://trac.macosforge.org/projects/calendarserver/changeset/6948
Author: glyph at apple.com
Date: 2011-02-16 06:28:56 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify syncToken
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:28:44 UTC (rev 6947)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py 2011-02-16 14:28:56 UTC (rev 6948)
@@ -80,6 +80,7 @@
# structured tables. (new, preferred)
_homeSchema = schema.CALENDAR_HOME
_homeMetaDataSchema = schema.CALENDAR_HOME_METADATA
+ _revisionsSchema = schema.CALENDAR_OBJECT_REVISIONS
# 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:28:44 UTC (rev 6947)
+++ CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py 2011-02-16 14:28:56 UTC (rev 6948)
@@ -67,6 +67,7 @@
# structured tables. (new, preferred)
_homeSchema = schema.ADDRESSBOOK_HOME
_homeMetaDataSchema = schema.ADDRESSBOOK_HOME_METADATA
+ _revisionsSchema = schema.ADDRESSBOOK_OBJECT_REVISIONS
# 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:28:44 UTC (rev 6947)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:28:56 UTC (rev 6948)
@@ -63,6 +63,7 @@
from twext.enterprise.dal.syntax import Select
from twext.enterprise.dal.syntax import Lock
from twext.enterprise.dal.syntax import Insert
+from twext.enterprise.dal.syntax import Max
from txdav.base.propertystore.base import PropertyName
from txdav.base.propertystore.none import PropertyStore as NonePropertyStore
@@ -635,21 +636,28 @@
self._children.pop(name, None)
+ @classproperty
+ def _syncTokenQuery(cls):
+ """
+ DAL Select statement to find the sync token.
+ """
+ rev = cls._revisionsSchema
+ bind = cls._bindSchema
+ return Select(
+ [Max(rev.REVISION)],
+ From=rev, Where=(
+ rev.RESOURCE_ID in Select(
+ [bind.RESOURCE_ID], From=bind,
+ Where=bind.HOME_RESOURCE_ID == Parameter("resourceID"))
+ ).Or((rev.HOME_RESOURCE_ID == Parameter("resourceID")).And(
+ rev.RESOURCE_ID == None))
+ )
+
+
@inlineCallbacks
def syncToken(self):
- revision = (yield self._txn.execSQL(
- """
- select max(%(REV:column_REVISION)s) from %(REV:name)s
- where %(REV:column_RESOURCE_ID)s in (
- select %(BIND:column_RESOURCE_ID)s from %(BIND:name)s
- where %(BIND:column_HOME_RESOURCE_ID)s = %%s
- ) or (
- %(REV:column_HOME_RESOURCE_ID)s = %%s and
- %(REV:column_RESOURCE_ID)s is null
- )
- """ % self._revisionBindJoinTable,
- [self._resourceID, self._resourceID,]
- ))[0][0]
+ revision = (yield self._syncTokenQuery.on(
+ self._txn, resourceID=self._resourceID))[0][0]
returnValue("%s#%s" % (self._resourceID, revision))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/1ef73edd/attachment.html>
More information about the calendarserver-changes
mailing list