[CalendarServer-changes] [2189] CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 4 14:22:02 PST 2008
Revision: 2189
http://trac.macosforge.org/projects/calendarserver/changeset/2189
Author: wsanchez at apple.com
Date: 2008-03-04 14:22:01 -0800 (Tue, 04 Mar 2008)
Log Message:
-----------
Pull up r2175: unknown timezone causes calendar data error
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/test/test_timezones.py
CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/timezones.py
Modified: CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/test/test_timezones.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/test/test_timezones.py 2008-03-04 21:50:42 UTC (rev 2188)
+++ CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/test/test_timezones.py 2008-03-04 22:22:01 UTC (rev 2189)
@@ -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/branches/release/CalendarServer-1.2-dev/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/timezones.py 2008-03-04 21:50:42 UTC (rev 2188)
+++ CalendarServer/branches/release/CalendarServer-1.2-dev/twistedcaldav/timezones.py 2008-03-04 22:22:01 UTC (rev 2189)
@@ -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/20080304/59f4e7a1/attachment.html
More information about the calendarserver-changes
mailing list