[CalendarServer-changes] [7223] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 18 12:18:15 PDT 2011
Revision: 7223
http://trac.macosforge.org/projects/calendarserver/changeset/7223
Author: cdaboo at apple.com
Date: 2011-03-18 12:18:15 -0700 (Fri, 18 Mar 2011)
Log Message:
-----------
Update format of sync-token property value to match latest spec.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/method/report_common.py
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/storebridge.py
CalendarServer/trunk/txdav/caldav/datastore/test/common.py
CalendarServer/trunk/txdav/common/datastore/file.py
CalendarServer/trunk/txdav/common/datastore/sql.py
Modified: CalendarServer/trunk/twistedcaldav/method/report_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_common.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/twistedcaldav/method/report_common.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -399,7 +399,7 @@
def getCacheEntry(cls, calresource, useruid, timerange):
key = calresource.resourceID() + "/" + useruid
- token = (yield calresource.getSyncToken())
+ token = (yield calresource.getInternalSyncToken())
entry = (yield fbcacher.get(key))
if entry:
@@ -422,7 +422,7 @@
def makeCacheEntry(cls, calresource, useruid, timerange, fbresults):
key = calresource.resourceID() + "/" + useruid
- token = (yield calresource.getSyncToken())
+ token = (yield calresource.getInternalSyncToken())
entry = cls(key, token, timerange, fbresults)
yield fbcacher.set(key, entry)
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -579,7 +579,7 @@
elif qname == customxml.GETCTag.qname() and (
self.isPseudoCalendarCollection() or self.isAddressBookCollection()
):
- returnValue(customxml.GETCTag.fromString((yield self.getSyncToken())))
+ returnValue(customxml.GETCTag.fromString((yield self.getInternalSyncToken())))
elif qname == davxml.SyncToken.qname() and config.EnableSyncReport and (
davxml.Report(SyncCollection(),) in self.supportedReports()
@@ -1330,13 +1330,15 @@
@inlineCallbacks
def whatchanged(self, client_token, depth):
- current_token = yield self.getSyncToken()
- current_uuid, current_revision = current_token.split("#", 1)
+ current_token = (yield self.getSyncToken())
+ current_uuid, current_revision = current_token[6:].split("_", 1)
current_revision = int(current_revision)
if client_token:
try:
- caluuid, revision = client_token.split("#", 1)
+ if not client_token.startswith("data:,"):
+ raise ValueError
+ caluuid, revision = client_token[6:].split("_", 1)
revision = int(revision)
# Check client token validity
@@ -1368,10 +1370,19 @@
# Now handled directly by newstore
raise NotImplementedError
+ @inlineCallbacks
def getSyncToken(self):
"""
Return current sync-token value.
"""
+
+ internal_token = (yield self.getInternalSyncToken())
+ returnValue("data:,%s" % (internal_token,))
+
+ def getInternalSyncToken(self):
+ """
+ Return current internal sync-token value.
+ """
raise HTTPError(StatusResponse(responsecode.NOT_FOUND, "Property not supported"))
#
@@ -2069,10 +2080,10 @@
Merge two sync tokens, choosing the higher revision number of the two,
but keeping the home resource-id intact.
"""
- homekey, homerev = hometoken.split("#", 1)
- notrev = notificationtoken.split("#", 1)[1]
+ homekey, homerev = hometoken.split("_", 1)
+ notrev = notificationtoken.split("_", 1)[1]
if int(notrev) > int(homerev):
- hometoken = "%s#%s" % (homekey, notrev,)
+ hometoken = "%s_%s" % (homekey, notrev,)
return hometoken
def canShare(self):
@@ -2455,12 +2466,12 @@
@inlineCallbacks
- def getSyncToken(self):
+ def getInternalSyncToken(self):
# The newstore implementation supports this directly
caltoken = yield self._newStoreHome.syncToken()
if config.Sharing.Enabled and config.Sharing.Calendars.Enabled:
- notificationtoken = yield (yield self.getChild("notification")).getSyncToken()
+ notificationtoken = yield (yield self.getChild("notification")).getInternalSyncToken()
# Merge tokens
caltoken = self._mergeSyncTokens(caltoken, notificationtoken)
@@ -2565,18 +2576,18 @@
@inlineCallbacks
- def getSyncToken(self):
+ def getInternalSyncToken(self):
# The newstore implementation supports this directly
adbktoken = yield self._newStoreHome.syncToken()
if config.Sharing.Enabled and config.Sharing.AddressBooks.Enabled and not config.Sharing.Calendars.Enabled:
- notifcationtoken = yield (yield self.getChild("notification")).getSyncToken()
+ notifcationtoken = yield (yield self.getChild("notification")).getInternalSyncToken()
# Merge tokens
- adbkkey, adbkrev = adbktoken.split("#", 1)
- notrev = notifcationtoken.split("#", 1)[1]
+ adbkkey, adbkrev = adbktoken.split("_", 1)
+ notrev = notifcationtoken.split("_", 1)[1]
if int(notrev) > int(adbkrev):
- adbktoken = "%s#%s" % (adbkkey, notrev,)
+ adbktoken = "%s_%s" % (adbkkey, notrev,)
returnValue(adbktoken)
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -319,7 +319,7 @@
return self._newStoreObject.created() if self._newStoreObject else None
- def getSyncToken(self):
+ def getInternalSyncToken(self):
return self._newStoreObject.syncToken() if self._newStoreObject else None
@inlineCallbacks
@@ -519,7 +519,7 @@
testctag = iffy[iffy.find(prefix):]
testctag = testctag[len(prefix):]
testctag = testctag.split(">", 1)[0]
- ctag = (yield self.getSyncToken())
+ ctag = (yield self.getInternalSyncToken())
if testctag != ctag:
raise HTTPError(StatusResponse(responsecode.PRECONDITION_FAILED, "CTag pre-condition failure"))
@@ -617,7 +617,7 @@
result = MultiStatusResponse(xmlresponses)
- newctag = (yield self.getSyncToken())
+ newctag = (yield self.getInternalSyncToken())
result.headers.setRawHeaders("CTag", (newctag,))
# Setup some useful logging
@@ -691,7 +691,7 @@
result = MultiStatusResponse(xmlresponses)
- newctag = (yield self.getSyncToken())
+ newctag = (yield self.getInternalSyncToken())
result.headers.setRawHeaders("CTag", (newctag,))
# Setup some useful logging
@@ -961,7 +961,7 @@
# Cache the data
data = str(calendar)
- data = (yield self.getSyncToken()) + "\r\n" + data
+ data = (yield self.getInternalSyncToken()) + "\r\n" + data
returnValue(calendar)
@@ -2081,7 +2081,7 @@
return True
- def getSyncToken(self):
+ def getInternalSyncToken(self):
return self._newStoreNotifications.syncToken()
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -1310,7 +1310,7 @@
now that logic lives in the protocol layer, so this testing method
replicates it.
"""
- uuid, rev = token.split("#", 1)
+ uuid, rev = token.split("_", 1)
rev = int(rev)
return rev
Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/txdav/common/datastore/file.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -456,14 +456,14 @@
maxrev = 0
for child in self.children():
- maxrev = max(int((yield child.syncToken()).split("#")[1]), maxrev)
+ maxrev = max(int((yield child.syncToken()).split("_")[1]), maxrev)
try:
urnuuid = str(self.properties()[PropertyName.fromElement(ResourceID)].children[0])
except KeyError:
urnuuid = uuid.uuid4().urn
self.properties()[PropertyName(*ResourceID.qname())] = ResourceID(HRef.fromString(urnuuid))
- returnValue("%s#%s" % (urnuuid[9:], maxrev))
+ returnValue("%s_%s" % (urnuuid[9:], maxrev))
def resourceNamesSinceToken(self, token, depth):
@@ -807,7 +807,7 @@
except KeyError:
urnuuid = uuid.uuid4().urn
self.properties()[PropertyName(*ResourceID.qname())] = ResourceID(HRef.fromString(urnuuid))
- return succeed("%s#%s" % (urnuuid[9:], self.retrieveOldIndex().lastRevision()))
+ return succeed("%s_%s" % (urnuuid[9:], self.retrieveOldIndex().lastRevision()))
def objectResourcesSinceToken(self, token):
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2011-03-18 19:14:17 UTC (rev 7222)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2011-03-18 19:18:15 UTC (rev 7223)
@@ -682,7 +682,7 @@
def syncToken(self):
revision = (yield self._syncTokenQuery.on(
self._txn, resourceID=self._resourceID))[0][0]
- returnValue("%s#%s" % (self._resourceID, revision))
+ returnValue("%s_%s" % (self._resourceID, revision))
@classproperty
@@ -962,7 +962,7 @@
if self._syncTokenRevision is None:
self._syncTokenRevision = (yield self._childSyncTokenQuery.on(
self._txn, resourceID=self._resourceID))[0][0]
- returnValue(("%s#%s" % (self._resourceID, self._syncTokenRevision,)))
+ returnValue(("%s_%s" % (self._resourceID, self._syncTokenRevision,)))
def objectResourcesSinceToken(self, token):
@@ -2540,7 +2540,7 @@
yield self._syncTokenQuery.on(
self._txn, resourceID=self._resourceID)
)[0][0]
- returnValue("%s#%s" % (self._resourceID, self._syncTokenRevision))
+ returnValue("%s_%s" % (self._resourceID, self._syncTokenRevision))
def properties(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110318/0f1780a4/attachment-0001.html>
More information about the calendarserver-changes
mailing list