[CalendarServer-changes] [2946] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Sat Sep 6 21:03:01 PDT 2008


Revision: 2946
          http://trac.macosforge.org/projects/calendarserver/changeset/2946
Author:   cdaboo at apple.com
Date:     2008-09-06 21:03:01 -0700 (Sat, 06 Sep 2008)
Log Message:
-----------
Some Organizer changes should not trigger an update to Attendees.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
    CalendarServer/trunk/twistedcaldav/scheduling/itip.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2008-09-06 20:10:32 UTC (rev 2945)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2008-09-07 04:03:01 UTC (rev 2946)
@@ -37,7 +37,6 @@
 from twistedcaldav.dateops import compareDateTime, normalizeToUTC, timeRangesOverlap
 from twistedcaldav.instance import InstanceList
 from twistedcaldav.log import Logger
-from types import ListType
 from vobject import newFromBehavior, readComponents
 from vobject.base import Component as vComponent, ContentLine as vContentLine, ParseError as vParseError
 from vobject.icalendar import TimezoneComponent, dateTimeToString, deltaToOffset, getTransition, stringToDate, stringToDateTime, stringToDurations, utc
@@ -1360,7 +1359,7 @@
                 if component.name() == "VALARM":
                     self.removeComponent(component)
                 
-    def removeUnwantedProperties(self, keep_properties):
+    def filterProperties(self, remove=None, keep=None):
         """
         Remove all properties that do not match the provided set.
         """
@@ -1371,7 +1370,10 @@
             for component in self.subcomponents():
                 if component.name() == "VTIMEZONE":
                     continue
-                [component.removeProperty(p) for p in tuple(component.properties()) if p.name() not in keep_properties]
+                if keep:
+                    [component.removeProperty(p) for p in tuple(component.properties()) if p.name() not in keep]
+                if remove:
+                    [component.removeProperty(p) for p in tuple(component.properties()) if p.name() in remove]
                 
     def removeXProperties(self, keep_properties):
         """
@@ -1390,6 +1392,25 @@
                     if p.name().startswith("X-") and p.name() not in keep_properties
                 ]
             
+    def removePropertyParameters(self, property, params):
+        """
+        Remove all specified property parameters
+        """
+
+        assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
+
+        if self.name() == "VCALENDAR":
+            for component in self.subcomponents():
+                if component.name() == "VTIMEZONE":
+                    continue
+                props = component.properties(property)
+                for prop in props:
+                    for param in params:
+                        try:
+                            del prop.params()[param]
+                        except KeyError:
+                            pass
+            
 ##
 # Dates and date-times
 ##

Modified: CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2008-09-06 20:10:32 UTC (rev 2945)
+++ CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2008-09-07 04:03:01 UTC (rev 2946)
@@ -51,8 +51,24 @@
         # Do straight comparison without alarms
         self.calendar1 = self.calendar1.duplicate()
         self.calendar1.removeAlarms()
+        self.calendar1.filterProperties(remove=(
+            "DTSTAMP",
+            "LAST-MODIFIED",
+        ))
+        self.calendar1.removePropertyParameters("ATTENDEE", (
+            "SCHEDULE-AGENT",
+            "SCHEDULE-STATUS",
+        ))
         self.calendar2 = self.calendar2.duplicate()
         self.calendar2.removeAlarms()
+        self.calendar2.filterProperties(remove=(
+            "DTSTAMP",
+            "LAST-MODIFIED",
+        ))
+        self.calendar2.removePropertyParameters("ATTENDEE", (
+            "SCHEDULE-AGENT",
+            "SCHEDULE-STATUS",
+        ))
 
         return self.calendar1 == self.calendar2
 

Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2008-09-06 20:10:32 UTC (rev 2945)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2008-09-07 04:03:01 UTC (rev 2946)
@@ -452,7 +452,7 @@
         itip.removeAlarms()
 
         # Remove all but essential properties
-        itip.removeUnwantedProperties((
+        itip.filterProperties(keep=(
             "UID",
             "RECURRENCE-ID",
             "SEQUENCE",

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2008-09-06 20:10:32 UTC (rev 2945)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2008-09-07 04:03:01 UTC (rev 2946)
@@ -1086,7 +1086,7 @@
             component.removeAllButOneAttendee(attendee)
             self.assertEqual(result, str(component).replace("\r", ""))
 
-    def test_remove_unwanted_properties(self):
+    def test_filter_properties_keep(self):
         
         data = (
             # One component
@@ -1174,9 +1174,101 @@
         
         for original, result, keep_properties in data:
             component = Component.fromString(original)
-            component.removeUnwantedProperties(keep_properties)
+            component.filterProperties(keep=keep_properties)
             self.assertEqual(result, str(component).replace("\r", ""))
 
+    def test_filter_properties_remove(self):
+        
+        data = (
+            # One component
+            (
+                """BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+SUMMARY:20071114T000000Z
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                ("DTSTART", "SUMMARY",),
+            ),
+
+            # Multiple components
+            (
+                """BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-3
+DTSTART:20071114T000000Z
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RRULE:FREQ=YEARLY
+BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:Test
+TRIGGER;RELATED=START:-PT10M
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20081114T000000Z
+DTSTART:20071114T010000Z
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-3
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RRULE:FREQ=YEARLY
+BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:Test
+TRIGGER;RELATED=START:-PT10M
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20081114T000000Z
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                ("DTSTART", "SUMMARY",),
+            ),
+
+        )
+        
+        for original, result, remove_properties in data:
+            component = Component.fromString(original)
+            component.filterProperties(remove=remove_properties)
+            self.assertEqual(result, str(component).replace("\r", ""))
+
     def test_remove_alarms(self):
         
         data = (
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080906/443b5056/attachment-0001.html 


More information about the calendarserver-changes mailing list