Initial sync-token and sync-collection support

Use the etag of the collection as the sync token and tell the client that the token is invalid when the collection changed.
This commit is contained in:
Unrud
2017-06-02 12:44:23 +02:00
parent 6bb0e9d956
commit f2b415c4a6
3 changed files with 49 additions and 5 deletions

View File

@ -300,6 +300,24 @@ class BaseCollection:
"""
raise NotImplementedError
def sync(self, old_token=None):
"""Get the current sync token and changed items for synchronization.
``old_token`` an old sync token which is used as the base of the
delta update. If sync token is missing, all items are returned.
ValueError is raised for invalid or old tokens.
WARNING: This simple default implementation treats all sync-token as
invalid. It adheres to the specification but some clients
(e.g. InfCloud) don't like it. Subclasses should provide a
more sophisticated implementation.
"""
token = "http://radicale.org/ns/sync/%s" % self.etag.strip("\"")
if old_token:
raise ValueError("Sync token are not supported")
return token, self.list()
def list(self):
"""List collection items."""
raise NotImplementedError