Title: [chandler1] (jeffrey) [16635] For Google CalDAV: Don' t include top level icalExtra more than once
Revision
16635
Author
jeffrey
Date
2009-01-28 14:12:24 -0800 (Wed, 28 Jan 2009)

Log Message

For Google CalDAV: Don't include top level icalExtra more than once

Modified Paths


Diff

Modified: trunk/chandler/parcels/osaf/sharing/ics.py (16634 => 16635)


--- trunk/chandler/parcels/osaf/sharing/ics.py	2009-01-28 22:12:19 UTC (rev 16634)
+++ trunk/chandler/parcels/osaf/sharing/ics.py	2009-01-28 22:12:24 UTC (rev 16635)
@@ -321,14 +321,15 @@
     
     return out.newComponent
 
-def injectUnrecognized(icalendarExtra, calendar, vevent):
+def injectUnrecognized(icalendarExtra, calendar, vevent, includeTopLevel=True):
     """Add unrecognized data from item.icalendarExtra to calendar and vevent."""
     if not icalendarExtra:
         # nothing to do
         return
     newCal = vobject.readOne(icalendarExtra, transform=False)
-    for line in newCal.lines():
-        calendar.contents.setdefault(line.name, []).append(line)
+    if includeTopLevel:
+        for line in newCal.lines():
+            calendar.contents.setdefault(line.name, []).append(line)
     for component in newCal.components():
         if component.name.lower() != 'vevent':
             calendar.contents.setdefault(component.name, []).append(component)
@@ -447,7 +448,8 @@
                     masterRecordSets.append( (uuid, recordSet) )
                 else:
                     nonMasterRecordSets.append( (uuid, recordSet) )
-        
+
+        injectTopLevel = True
         for uuid, recordSet in chain(masterRecordSets, nonMasterRecordSets):
             prepareVobj(view, uuid, recordSet, vobj_mapping)
             icalExtra = None
@@ -458,8 +460,11 @@
                     icalExtra = record.icalExtra
             
             if icalExtra not in translator.emptyValues:
-                injectUnrecognized(icalExtra, cal, vobj_mapping.get(uuid))
-            
+                injectUnrecognized(icalExtra, cal, vobj_mapping.get(uuid),
+                                   injectTopLevel)
+                # only include unrecognized content lines once per cluster
+                injectTopLevel = False
+
         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()
@@ -469,8 +474,7 @@
         if name is not None:
             cal.add('x-wr-calname').value = name
             
-        monolithic = extra.get('monolithic', False)
-        if monolithic:
+        if extra.get('monolithic', False):
             # don't add a METHOD to CalDAV serializations, because CalDAV
             # forbids them, but do add one when serializing monolithic ics files
             # because Outlook requires them (bug 7121)
_______________________________________________
commits mailing list
commits@osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to