[CalendarServer-changes] [3889] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 18 17:34:07 PDT 2009


Revision: 3889
          http://trac.macosforge.org/projects/calendarserver/changeset/3889
Author:   cdaboo at apple.com
Date:     2009-03-18 17:34:06 -0700 (Wed, 18 Mar 2009)
Log Message:
-----------
Optimize partial auto-accept behavior by setting the master instance's PARTSTAT to the status that
minimizes the number of overridden instances.

Modified Paths:
--------------
    CalendarServer/trunk/run
    CalendarServer/trunk/twistedcaldav/scheduling/processing.py

Modified: CalendarServer/trunk/run
===================================================================
--- CalendarServer/trunk/run	2009-03-19 00:32:34 UTC (rev 3888)
+++ CalendarServer/trunk/run	2009-03-19 00:34:06 UTC (rev 3889)
@@ -711,7 +711,7 @@
 
 caldavtester="${top}/CalDAVTester";
 
-svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 3885;
+svn_get "CalDAVTester" "${caldavtester}" "${svn_uri_base}/CalDAVTester/trunk" 3888;
 
 #
 # PyFlakes

Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2009-03-19 00:32:34 UTC (rev 3888)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2009-03-19 00:34:06 UTC (rev 3889)
@@ -498,20 +498,23 @@
             made_changes = False
             partstat = "MIXED RESPONSE"
 
+            # Default state is whichever of ACCEPTED or DECLINED has most instances
+            defaultStateAccepted = len(filter(lambda x:x, instance_states.values())) >= len(instance_states.keys()) / 2
+
             # See if there is a master component first
             master = calendar.masterComponent()
             if master:
                 attendee = master.getAttendeeProperty(cuas)
                 if attendee:
-                    made_changes |= self.changeAttendeePartstat(attendee, "ACCEPTED")
-                    master.replaceProperty(Property("TRANSP", "OPAQUE"))
+                    made_changes |= self.changeAttendeePartstat(attendee, "ACCEPTED" if defaultStateAccepted else "DECLINED")
+                    master.replaceProperty(Property("TRANSP", "OPAQUE" if defaultStateAccepted else "TRANSPARENT"))
 
             # Look at expanded instances and change partstat accordingly
-            for instance, accepted in instance_states.iteritems():
+            for instance, accepted in sorted(instance_states.iteritems(), key=lambda x: x[0].rid):
                 
                 overridden = calendar.overriddenComponent(instance.rid)
-                if not overridden and accepted:
-                    # Nothing to do as master is always ACCEPTED
+                if not overridden and accepted == defaultStateAccepted:
+                    # Nothing to do as state matches the master
                     continue 
                 
                 if overridden:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090318/13c2d37b/attachment.html>


More information about the calendarserver-changes mailing list