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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 21 21:07:35 PST 2008


Revision: 2175
          http://trac.macosforge.org/projects/calendarserver/changeset/2175
Author:   cdaboo at apple.com
Date:     2008-02-21 21:07:34 -0800 (Thu, 21 Feb 2008)

Log Message:
-----------
Make sure we can handle timezones that are not in our cache. Ticket #216.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_timezones.py
    CalendarServer/trunk/twistedcaldav/timezones.py

Modified: CalendarServer/trunk/twistedcaldav/test/test_timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2008-02-22 04:14:12 UTC (rev 2174)
+++ CalendarServer/trunk/twistedcaldav/test/test_timezones.py	2008-02-22 05:07:34 UTC (rev 2175)
@@ -126,3 +126,50 @@
         self.assertTrue(tzcache.loadTimezone("America/New_York"))
         self.assertTrue(tzcache.loadTimezone("US/Eastern"))
         tzcache.unregister()
+
+    def test_not_in_cache(self):
+        
+        tzcache = TimezoneCache()
+        tzcache.register()
+
+        data = """BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VTIMEZONE
+TZID:US-Eastern
+LAST-MODIFIED:19870101T000000Z
+BEGIN:STANDARD
+DTSTART:19671029T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+TZNAME:Eastern Standard Time (US & Canada)
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:19870405T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+TZNAME:Eastern Daylight Time (US & Canada)
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART;TZID="US-Eastern":20071225T000000
+DTEND;TZID="US-Eastern":20071225T010000
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+        calendar = Component.fromString(data)
+        if calendar.name() != "VCALENDAR": self.fail("Calendar is not a VCALENDAR")
+        instances = calendar.expandTimeRanges(datetime.date(2100, 1, 1))
+        for key in instances:
+            instance = instances[key]
+            start = instance.start
+            end = instance.end
+            self.assertEqual(start, datetime.datetime(2007, 12, 25, 05, 0, 0, tzinfo=utc))
+            self.assertEqual(end, datetime.datetime(2007, 12, 25, 06, 0, 0, tzinfo=utc))
+            break;
+        tzcache.unregister()

Modified: CalendarServer/trunk/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/timezones.py	2008-02-22 04:14:12 UTC (rev 2174)
+++ CalendarServer/trunk/twistedcaldav/timezones.py	2008-02-22 05:07:34 UTC (rev 2175)
@@ -18,6 +18,8 @@
 
 from twistedcaldav.ical import Component
 
+from twisted.python import log
+
 from vobject.icalendar import getTzid
 from vobject.icalendar import registerTzid
 
@@ -79,7 +81,12 @@
     def registerTzidFromCache(self, tzid, tzinfo):
         if not self._caching:
             self._caching = True
-            self.loadTimezone(tzid)
+            try:
+                self.loadTimezone(tzid)
+            except TimezoneException:
+                # Fallback to vobject processing the actual tzdata
+                log.err("Cannot load timezone data for %s from timezone cache" % (tzid,))
+                self.vobjectRegisterTzid(tzid, tzinfo)
             self._caching = False
         else:
             self.vobjectRegisterTzid(tzid, tzinfo)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080221/3ed96684/attachment.html 


More information about the calendarserver-changes mailing list