[CalendarServer-changes] [13262] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 11 10:26:36 PDT 2014


Revision: 13262
          http://trac.calendarserver.org//changeset/13262
Author:   cdaboo at apple.com
Date:     2014-04-11 10:26:36 -0700 (Fri, 11 Apr 2014)
Log Message:
-----------
Add accounting logging for invalid instance errors. Also tweak recently added accounting to use base64 encoding of UIDs.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2014-04-11 17:25:39 UTC (rev 13261)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2014-04-11 17:26:36 UTC (rev 13262)
@@ -39,10 +39,12 @@
 from txweb2.stream import IStream
 from txweb2.dav.util import allDataFromStream
 
+from twistedcaldav.accounting import accountingEnabledForCategory, \
+    emitAccounting
 from twistedcaldav.config import config
 from twistedcaldav.dateops import timeRangesOverlap, normalizeForIndex, differenceDateTime, \
     normalizeForExpand
-from twistedcaldav.instance import InstanceList
+from twistedcaldav.instance import InstanceList, InvalidOverriddenInstanceError
 from txdav.caldav.datastore.scheduling.cuaddress import normalizeCUAddr
 from twistedcaldav.timezones import hasTZ, TimezoneException
 
@@ -1456,7 +1458,16 @@
 
         # Set of instances to return
         instances = InstanceList(ignoreInvalidInstances=ignoreInvalidInstances, normalizeFunction=normalizeFunction)
-        instances.expandTimeRanges(componentSet, limit, lowerLimit=lowerLimit)
+        try:
+            instances.expandTimeRanges(componentSet, limit, lowerLimit=lowerLimit)
+        except InvalidOverriddenInstanceError as e:
+            if accountingEnabledForCategory("Invalid Instance"):
+                emitAccounting(
+                    "Invalid Instance",
+                    self.resourceUID().encode("base64")[:-1],
+                    "{}\n\n{}".format(str(e), str(self)),
+                )
+            raise
         return instances
 
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2014-04-11 17:25:39 UTC (rev 13261)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2014-04-11 17:26:36 UTC (rev 13262)
@@ -4310,6 +4310,64 @@
 """,
             ),
             (
+                "3.4 - valid end of month",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:America/Chicago
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
+TZNAME:CDT
+TZOFFSETFROM:-0600
+TZOFFSETTO:-0500
+END:DAYLIGHT
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
+TZNAME:CST
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0600
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART;TZID=America/Chicago:20130830T100000
+DTEND;TZID=America/Chicago:20130830T110000
+CREATED:20130822T011010Z
+DTSTAMP:20131025T180410Z
+RRULE:FREQ=MONTHLY;INTERVAL=3
+SEQUENCE:8
+SUMMARY:Test
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID;TZID=America/Chicago:20131130T100000
+DTSTART;TZID=America/Chicago:20131130T100000
+DTEND;TZID=America/Chicago:20131130T110000
+CREATED:20130822T011010Z
+DTSTAMP:20131025T180410Z
+SEQUENCE:8
+STATUS:CANCELLED
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR""",
+                DateTime(2014, 8, 30, 10, 0, 0, Timezone(tzid="America/Chicago")),
+                """BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID;TZID=America/Chicago:20140830T100000
+DTSTART;TZID=America/Chicago:20140830T100000
+DTEND;TZID=America/Chicago:20140830T110000
+CREATED:20130822T011010Z
+DTSTAMP:20131025T180410Z
+SEQUENCE:8
+SUMMARY:Test
+END:VEVENT
+""",
+            ),
+            (
                 "4.1 - invalid all-day simple",
                 """BEGIN:VCALENDAR
 VERSION:2.0

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2014-04-11 17:25:39 UTC (rev 13261)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2014-04-11 17:26:36 UTC (rev 13262)
@@ -446,7 +446,7 @@
                         "AutoScheduling",
                         self.recipient.principal,
                         json.dumps(accounting) + "\r\n",
-                        filename=self.uid + ".txt"
+                        filename=self.uid.encode("base64")[:-1] + ".txt"
                     )
 
                 # Only store inbox item when reply is not sent or always for users
@@ -487,7 +487,7 @@
                             "AutoScheduling",
                             self.recipient.principal,
                             json.dumps(accounting) + "\r\n",
-                            filename=self.uid + ".txt"
+                            filename=self.uid.encode("base64")[:-1] + ".txt"
                         )
 
                     # Only store inbox item when reply is not sent or always for users
@@ -582,7 +582,7 @@
                         "AutoScheduling",
                         self.recipient.principal,
                         json.dumps(accounting) + "\r\n",
-                        filename=self.uid + ".txt"
+                        filename=self.uid.encode("base64")[:-1] + ".txt"
                     )
 
                 if delete_original:

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py	2014-04-11 17:25:39 UTC (rev 13261)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py	2014-04-11 17:26:36 UTC (rev 13262)
@@ -241,6 +241,59 @@
 END:VCALENDAR
 """,
             ),
+            (
+                "2.1 Recurring Request - date change, partstat mismatch",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+""",
+            ),
         )
 
         for title, calendar_txt, itip_txt, changed_txt in data:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140411/cd08d944/attachment.html>


More information about the calendarserver-changes mailing list