[CalendarServer-changes] [9698] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 13 17:17:15 PDT 2012


Revision: 9698
          http://trac.macosforge.org/projects/calendarserver/changeset/9698
Author:   cdaboo at apple.com
Date:     2012-08-13 17:17:15 -0700 (Mon, 13 Aug 2012)
Log Message:
-----------
Use more compact per-user calendar data representation. Don't write transparency table entries for
users with the default transparency.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/datafilters/peruserdata.py
    CalendarServer/trunk/twistedcaldav/datafilters/test/test_peruserdata.py
    CalendarServer/trunk/txdav/caldav/datastore/sql.py

Modified: CalendarServer/trunk/twistedcaldav/datafilters/peruserdata.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/datafilters/peruserdata.py	2012-08-14 00:14:31 UTC (rev 9697)
+++ CalendarServer/trunk/twistedcaldav/datafilters/peruserdata.py	2012-08-14 00:17:15 UTC (rev 9698)
@@ -223,7 +223,6 @@
             peruser = Component(PerUserDataFilter.PERUSER_COMPONENT)
             peruser.addProperty(Property("UID", ical.resourceUID()))
             peruser.addProperty(Property(PerUserDataFilter.PERUSER_UID, self.uid))
-            ical.addComponent(peruser)
             return peruser
         
         components = tuple(ical.subcomponents())
@@ -233,21 +232,18 @@
         for component in components:
             if component.name() == "VTIMEZONE":
                 continue
+            rid = component.getRecurrenceIDUTC()
 
-            def init_perinstance_component():
-                peruser = Component(PerUserDataFilter.PERINSTANCE_COMPONENT)
-                rid = component.getRecurrenceIDUTC()
-                perinstance_components[rid] = peruser
-                return peruser
+            perinstance_component = Component(PerUserDataFilter.PERINSTANCE_COMPONENT) if self.uid else None
+            perinstance_id_different = False
 
-            perinstance_component = init_perinstance_component() if self.uid else None
-            
             # Transfer per-user properties from main component to per-instance component
             for property in tuple(component.properties()):
                 if property.name() in PerUserDataFilter.PERUSER_PROPERTIES or property.name().startswith("X-"):
                     if self.uid:
                         perinstance_component.addProperty(property)
                     component.removeProperty(property)
+                    perinstance_id_different = True
             
             # Transfer per-user components from main component to per-instance component
             for subcomponent in tuple(component.subcomponents()):
@@ -255,19 +251,29 @@
                     if self.uid:
                         perinstance_component.addComponent(subcomponent)
                     component.removeComponent(subcomponent)
+                    perinstance_id_different = True
             
+            if perinstance_id_different and perinstance_component:
+                perinstance_components[rid] = perinstance_component
+            
         if self.uid:
             # Add unique per-instance components into the per-user component
+            peruser_component_different = False
             master_perinstance = perinstance_components.get(None)
             if master_perinstance:
                 peruser_component.addComponent(master_perinstance)
+                peruser_component_different = True
             for rid, perinstance in perinstance_components.iteritems():
                 if rid is None:
                     continue
                 if master_perinstance is None or perinstance != master_perinstance:
                     perinstance.addProperty(Property("RECURRENCE-ID", rid))
                     peruser_component.addComponent(perinstance)
-    
+                    peruser_component_different = True
+            
+            if peruser_component_different:
+                ical.addComponent(peruser_component)
+
             self._compactInstances(ical)
 
     def _compactInstances(self, ical):

Modified: CalendarServer/trunk/twistedcaldav/datafilters/test/test_peruserdata.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/datafilters/test/test_peruserdata.py	2012-08-14 00:14:31 UTC (rev 9697)
+++ CalendarServer/trunk/twistedcaldav/datafilters/test/test_peruserdata.py	2012-08-14 00:17:15 UTC (rev 9698)
@@ -959,12 +959,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         
@@ -1123,12 +1117,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         
@@ -1420,8 +1408,6 @@
 UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user01
 BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-BEGIN:X-CALENDARSERVER-PERINSTANCE
 RECURRENCE-ID:20080602T120000Z
 TRANSP:TRANSPARENT
 BEGIN:VALARM
@@ -1716,12 +1702,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -1993,12 +1973,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -2048,12 +2022,6 @@
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 RRULE:FREQ=DAILY
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -2125,12 +2093,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -2182,13 +2144,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-RECURRENCE-ID:20080602T120000Z
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -2900,12 +2855,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -3013,12 +2962,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -3105,13 +3048,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-RECURRENCE-ID:20080602T120000Z
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         
@@ -3151,12 +3087,6 @@
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 RRULE:FREQ=DAILY
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -3209,12 +3139,6 @@
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 RRULE:FREQ=DAILY
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -3275,12 +3199,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -3954,12 +3872,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -4067,12 +3979,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -4160,12 +4066,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         
@@ -4205,12 +4105,6 @@
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 RRULE:FREQ=DAILY
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -4492,12 +4386,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -4595,12 +4483,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -4670,12 +4552,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -5132,12 +5008,6 @@
 END:VEVENT
 BEGIN:X-CALENDARSERVER-PERUSER
 UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
 X-CALENDARSERVER-PERUSER-UID:user02
 BEGIN:X-CALENDARSERVER-PERINSTANCE
 TRANSP:OPAQUE
@@ -5187,13 +5057,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-RECURRENCE-ID:20080602T120000Z
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         olddata = """BEGIN:VCALENDAR
@@ -5468,13 +5331,6 @@
 DTSTAMP:20080601T120000Z
 ORGANIZER;CN=User 01:mailto:user1 at example.com
 END:VEVENT
-BEGIN:X-CALENDARSERVER-PERUSER
-UID:12345-67890
-X-CALENDARSERVER-PERUSER-UID:user01
-BEGIN:X-CALENDARSERVER-PERINSTANCE
-RECURRENCE-ID:20080602T120000Z
-END:X-CALENDARSERVER-PERINSTANCE
-END:X-CALENDARSERVER-PERUSER
 END:VCALENDAR
 """.replace("\n", "\r\n")
         

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2012-08-14 00:14:31 UTC (rev 9697)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2012-08-14 00:17:15 UTC (rev 9698)
@@ -1100,12 +1100,13 @@
             tr.TRANSPARENT                 : transp,
         }, Return=tr.INSTANCE_ID).on(txn))[0][0]
         peruserdata = component.perUserTransparency(rid)
-        for useruid, transp in peruserdata:
-            (yield Insert({
-                tpy.TIME_RANGE_INSTANCE_ID : instanceid,
-                tpy.USER_ID                : useruid,
-                tpy.TRANSPARENT            : transp,
-            }).on(txn))
+        for useruid, usertransp in peruserdata:
+            if usertransp != transp:
+                (yield Insert({
+                    tpy.TIME_RANGE_INSTANCE_ID : instanceid,
+                    tpy.USER_ID                : useruid,
+                    tpy.TRANSPARENT            : usertransp,
+                }).on(txn))
 
 
     @inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120813/021673b5/attachment-0001.html>


More information about the calendarserver-changes mailing list