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

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 17 20:05:36 PDT 2011


Revision: 7214
          http://trac.macosforge.org/projects/calendarserver/changeset/7214
Author:   cdaboo at apple.com
Date:     2011-03-17 20:05:36 -0700 (Thu, 17 Mar 2011)
Log Message:
-----------
Fix freebusy cache + all-day events.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/method/report_common.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2011-03-18 03:03:18 UTC (rev 7213)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2011-03-18 03:05:36 UTC (rev 7214)
@@ -296,33 +296,16 @@
     @classmethod
     def allFromString(clazz, string):
         """
-        Construct a L{Component} from a string.
-        @param string: a string containing iCalendar data.
-        @return: a C{list} of L{Component}s representing the components described by
-            C{string}.
+        Just default to reading a single VCALENDAR
         """
-        if type(string) is unicode:
-            string = string.encode("utf-8")
-        return clazz.allFromStream(StringIO.StringIO(string))
+        return clazz.fromString(string)
 
     @classmethod
     def allFromStream(clazz, stream):
         """
-        Construct possibly multiple L{Component}s from a stream.
-        @param stream: a C{read()}able stream containing iCalendar data.
-        @return: a C{list} of L{Component}s representing the components described by
-            C{stream}.
+        Just default to reading a single VCALENDAR
         """
-        
-        results = []
-        try:
-            for vobject in readComponents(stream):
-                results.append(clazz(None, vobject=vobject))
-            return results
-        except vParseError, e:
-            raise InvalidICalendarDataError(e)
-        except StopIteration, e:
-            raise InvalidICalendarDataError(e)
+        return clazz.fromStream(stream)
 
     @classmethod
     def fromString(clazz, string):

Modified: CalendarServer/trunk/twistedcaldav/method/report_common.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_common.py	2011-03-18 03:03:18 UTC (rev 7213)
+++ CalendarServer/trunk/twistedcaldav/method/report_common.py	2011-03-18 03:05:36 UTC (rev 7214)
@@ -470,6 +470,13 @@
     else:
         useruid = ""
             
+    # Get the timezone property from the collection.
+    has_prop = (yield calresource.hasProperty((caldav_namespace, "calendar-timezone"), request))
+    if has_prop:
+        tz = (yield calresource.readProperty((caldav_namespace, "calendar-timezone"), request))
+    else:
+        tz = None
+
     # Try cache
     resources = (yield FBCacheEntry.getCacheEntry(calresource, useruid, timerange)) if config.EnableFreeBusyCache else None
 
@@ -508,14 +515,6 @@
                        )
                   )
         filter = calendarqueryfilter.Filter(filter)
-    
-        # Get the timezone property from the collection, and store in the query filter
-        # for use during the query itself.
-        has_prop = (yield calresource.hasProperty((caldav_namespace, "calendar-timezone"), request))
-        if has_prop:
-            tz = (yield calresource.readProperty((caldav_namespace, "calendar-timezone"), request))
-        else:
-            tz = None
         tzinfo = filter.settimezone(tz)
     
         try:
@@ -533,6 +532,20 @@
             request.extendedLogItems = {}
         request.extendedLogItems["fb-cached"] = request.extendedLogItems.get("fb-cached", 0) + 1
 
+        # Determine appropriate timezone (UTC is the default)
+        tzinfo = None
+        if tz is not None:
+            calendar = tz.calendar()
+            if calendar is not None:
+                for subcomponent in calendar.subcomponents():
+                    if subcomponent.name() == "VTIMEZONE":
+                        # <filter> contains exactly one <comp-filter>
+                        tzinfo = subcomponent.gettimezone()
+                        break
+
+        if tzinfo is None:
+            tzinfo = PyCalendarTimezone(utc=True)
+
     # We care about separate instances for VEVENTs only
     aggregated_resources = {}
     for name, uid, type, test_organizer, float, start, end, fbtype, transp in resources:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110317/8c9e4b31/attachment.html>


More information about the calendarserver-changes mailing list