[CalendarServer-changes] [4069] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 23 09:26:23 PDT 2009


Revision: 4069
          http://trac.macosforge.org/projects/calendarserver/changeset/4069
Author:   cdaboo at apple.com
Date:     2009-04-23 09:26:22 -0700 (Thu, 23 Apr 2009)
Log Message:
-----------
Check for case where ORGANIZER property is not present in all components.

Modified Paths:
--------------
    CalendarServer/trunk/run
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run	2009-04-23 16:24:45 UTC (rev 4068)
+++ CalendarServer/trunk/run	2009-04-23 16:26:22 UTC (rev 4069)
@@ -724,7 +724,7 @@
 
 caldavtester="${top}/CalDAVTester";
 
-svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 4050;
+svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 4068;
 
 #
 # PyFlakes

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2009-04-23 16:24:45 UTC (rev 4068)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2009-04-23 16:26:22 UTC (rev 4069)
@@ -1254,6 +1254,38 @@
                     "Timezone %s is not referenced by any non-timezone component" % (timezone,)
                 )
 
+    def validOrganizerForScheduling(self):
+        """
+        Check that the ORGANIZER property is valid for scheduling 
+        """
+        
+        organizers = self.getOrganizersByInstance()
+        foundOrganizer = None
+        foundRid = None
+        missingRids = set()
+        for organizer, rid in organizers:
+            if organizer:
+                if foundOrganizer:
+                    if organizer != foundOrganizer:
+                        # We have different ORGANIZERs in the same iCalendar object - this is an error
+                        msg = "Only one ORGANIZER is allowed in an iCalendar object:\n%s" % (self,)
+                        log.debug(msg)
+                        raise ValueError(msg)
+                else:
+                    foundOrganizer = organizer
+                    foundRid = rid
+            else:
+                missingRids.add(rid)
+        
+        # If there are some components without an ORGANIZER we will fix the data
+        if foundOrganizer and missingRids:
+            log.debug("Fixing missing ORGANIZER properties")
+            organizerProperty = self.overriddenComponent(foundRid).getProperty("ORGANIZER")
+            for rid in missingRids:
+                self.overriddenComponent(rid).addProperty(organizerProperty)
+
+        return foundOrganizer
+
     def transformAllFromNative(self):
         self._vobject = self._vobject.transformFromNative()
         self._vobject.transformChildrenFromNative(False)
@@ -1370,8 +1402,7 @@
                 # Should be just one ORGANIZER
                 org = self.propertyValue("ORGANIZER")
                 rid = self.getRecurrenceIDUTC()
-                if org:
-                    return ((org, rid),)
+                return ((org, rid),)
             except ValueError:
                 pass
 

Modified: CalendarServer/trunk/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2009-04-23 16:24:45 UTC (rev 4068)
+++ CalendarServer/trunk/twistedcaldav/scheduling/implicit.py	2009-04-23 16:26:22 UTC (rev 4069)
@@ -311,16 +311,12 @@
                             break
 
         # Get the ORGANIZER and verify it is the same for all components
-        organizers = self.calendar.getOrganizersByInstance()
-        self.organizer = None
-        for organizer, _ignore in organizers:
-            if self.organizer:
-                if organizer != self.organizer:
-                    # We have different ORGANIZERs in the same iCalendar object - this is an error
-                    log.error("Only one ORGANIZER is allowed in an iCalendar object:\n%s" % (self.calendar,))
-                    raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "single-organizer")))
-            else:
-                self.organizer = organizer
+        try:
+            self.organizer = self.calendar.validOrganizerForScheduling()
+        except ValueError:
+            # We have different ORGANIZERs in the same iCalendar object - this is an error
+            log.error("Only one ORGANIZER is allowed in an iCalendar object:\n%s" % (self.calendar,))
+            raise HTTPError(ErrorResponse(responsecode.FORBIDDEN, (caldav_namespace, "single-organizer")))
         
         # Get the ATTENDEEs
         self.attendeesByInstance = self.calendar.getAttendeesByInstance()

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2009-04-23 16:24:45 UTC (rev 4068)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2009-04-23 16:26:22 UTC (rev 4069)
@@ -264,7 +264,9 @@
 END:VEVENT
 END:VCALENDAR
 """,
-                ()
+                (
+                    (None, None),
+                )
             ),
             (
                 """BEGIN:VCALENDAR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090423/911a101f/attachment.html>


More information about the calendarserver-changes mailing list