Title: [chandler1] (jeffrey) [16638] For Google CalDAV: Increment SEQUENCE when doing CalDAV sharing,
Revision
16638
Author
jeffrey
Date
2009-01-28 14:12:35 -0800 (Wed, 28 Jan 2009)

Log Message

For Google CalDAV: Increment SEQUENCE when doing CalDAV sharing,
because Google is adamant about this (it'll return 409 DTSTAMP
must be newer, but DTSTAMPs are all newer, SEQUENCE is the secret)

Modified Paths

Diff

Modified: trunk/chandler/parcels/osaf/sharing/caldav_conduit.py (16637 => 16638)


--- trunk/chandler/parcels/osaf/sharing/caldav_conduit.py	2009-01-28 22:12:31 UTC (rev 16637)
+++ trunk/chandler/parcels/osaf/sharing/caldav_conduit.py	2009-01-28 22:12:35 UTC (rev 16638)
@@ -31,6 +31,7 @@
 
 class CalDAVRecordSetConduit(webdav_conduit.WebDAVRecordSetConduit):
 
+    incrementSequence = True
     pathMatchesUUID   = True
 
     def _createCollectionResource(self, handle, resource, childName):

Modified: trunk/chandler/parcels/osaf/sharing/ics.py (16637 => 16638)


--- trunk/chandler/parcels/osaf/sharing/ics.py	2009-01-28 22:12:31 UTC (rev 16637)
+++ trunk/chandler/parcels/osaf/sharing/ics.py	2009-01-28 22:12:35 UTC (rev 16638)
@@ -421,7 +421,27 @@
             break
     return note, event
 
+def setHigherSequence(vevents):
+    """
+    Google's CalDAV implementation insists that SEQUENCE be
+    incremented when it receives a change to an item (in some
+    circumstances, at least).  Any new modifications need to have a
+    high SEQUENCE, too.
 
+    """
+    highestSequence = 0
+    # find the highest sequence number
+    for vevent in vevents:
+        sequence = getattr(vevent, 'sequence', None)
+        if sequence:
+            highestSequence = max(int(sequence.value), highestSequence)
+        else:
+            vevent.add('sequence')
+
+    for vevent in vevents:
+        vevent.sequence.value = str(highestSequence + 1)
+
+
 class ICSSerializer(object):
 
     @classmethod
@@ -465,6 +485,10 @@
                 # only include unrecognized content lines once per cluster
                 injectTopLevel = False
 
+        # Tweak SEQUENCE for Google
+        if extra.get('incrementSequence', False):
+            setHigherSequence(vobj_mapping.values())
+
         cal.vevent_list = [obj for obj in vobj_mapping.values()
                            if obj.name.lower() == 'vevent']
         cal.vtodo_list = [obj for obj in vobj_mapping.values()

Modified: trunk/chandler/parcels/osaf/sharing/recordset_conduit.py (16637 => 16638)


--- trunk/chandler/parcels/osaf/sharing/recordset_conduit.py	2009-01-28 22:12:31 UTC (rev 16637)
+++ trunk/chandler/parcels/osaf/sharing/recordset_conduit.py	2009-01-28 22:12:35 UTC (rev 16638)
@@ -70,6 +70,7 @@
     lastVersion = schema.One(schema.Long, initialValue=0)
 
     _allTickets = ()
+    incrementSequence = False
     pathMatchesUUID = False
 
     def sync(self, modeOverride=None, activity=None, forceUpdate=None,
@@ -1009,7 +1010,8 @@
 
             extra = { 'rootName' : 'collection',
                       'uuid' : share.contents.itsUUID.str16(),
-                      'name' : share.displayName
+                      'name' : share.displayName,
+                      'incrementSequence' : 'increment' if self.incrementSequence else ''
                     }
 
             aliases = toSend.keys()
_______________________________________________
commits mailing list
commits@osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to