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

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 13 21:04:32 PDT 2007


Revision: 1376
          http://trac.macosforge.org/projects/calendarserver/changeset/1376
Author:   cdaboo at apple.com
Date:     2007-03-13 21:04:31 -0700 (Tue, 13 Mar 2007)

Log Message:
-----------
Change to availability to use property on inbox rather than components in calendars.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/config.py
    CalendarServer/trunk/twistedcaldav/customxml.py
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/resource.py
    CalendarServer/trunk/twistedcaldav/schedule.py

Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py	2007-03-14 04:01:49 UTC (rev 1375)
+++ CalendarServer/trunk/twistedcaldav/config.py	2007-03-14 04:04:31 UTC (rev 1376)
@@ -64,11 +64,11 @@
     #    users, groups, locations and resources) to the server.
     #
     "DirectoryService": {
-        "type": "twistedcaldav.directory.appleopendirectory.OpenDirectoryService",
-        "params": {
-            "node": "/Search",
-            "requireComputerRecord": True,
-        },
+#        "type": "twistedcaldav.directory.appleopendirectory.OpenDirectoryService",
+#        "params": {
+#            "node": "/Search",
+#            "requireComputerRecord": True,
+#        },
     },
 
     #

Modified: CalendarServer/trunk/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/customxml.py	2007-03-14 04:01:49 UTC (rev 1375)
+++ CalendarServer/trunk/twistedcaldav/customxml.py	2007-03-14 04:04:31 UTC (rev 1376)
@@ -28,6 +28,8 @@
 from twisted.web2.dav.resource import twisted_dav_namespace
 from twisted.web2.dav import davxml
 
+from twistedcaldav.ical import Component as iComponent
+
 calendarserver_namespace = "http://calendarserver.org/ns/"
 
 class TwistedGUIDProperty (davxml.WebDAVTextElement):
@@ -216,6 +218,50 @@
     name = "getctag"
     protected = True
 
+class CalendarAvailability (davxml.WebDAVTextElement):
+    """
+    Contains the calendar availability property.
+    """
+    namespace = calendarserver_namespace
+    name = "calendar-availability"
+    hidden = True
+
+
+    def calendar(self):
+        """
+        Returns a calendar component derived from this element.
+        """
+        return iComponent.fromString(str(self))
+
+    def valid(self):
+        """
+        Determine whether the content of this element is a valid single VAVAILABILITY component,
+        with zero or more VTIEMZONE components.
+
+        @return: True if valid, False if not.
+        """
+        
+        try:
+            calendar = self.calendar()
+            if calendar is None:
+                return False
+        except ValueError:
+            return False
+
+        found = False
+        for subcomponent in calendar.subcomponents():
+            if subcomponent.name() == "VAVAILABILITY":
+                if found:
+                    return False
+                else:
+                    found = True
+            elif subcomponent.name() == "VTIMEZONE":
+                continue
+            else:
+                return False
+
+        return found
+
 ##
 # Extensions to davxml.ResourceType
 ##

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2007-03-14 04:01:49 UTC (rev 1375)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2007-03-14 04:04:31 UTC (rev 1376)
@@ -51,6 +51,15 @@
 
 iCalendarProductID = "-//CALENDARSERVER.ORG//NONSGML Version 1//EN"
 
+allowedComponents = (
+    "VEVENT",
+    "VTODO",
+    "VTIMEZONE",
+    "VJOURNAL",
+    "VFREEBUSY",
+    #"VAVAILABILITY",
+)
+
 class Property (object):
     """
     iCalendar Property
@@ -770,6 +779,9 @@
                         raise ValueError("Calendar resources may not contain more than one type of calendar " +
                                          "component (%s and %s found)" % (ctype, subcomponent.name()))
         
+                if ctype not in allowedComponents:
+                    raise ValueError("Component type: %s not allowed" % (ctype,))
+                    
                 uid = subcomponent.propertyValue("UID")
                 if uid is None:
                     raise ValueError("All components must have UIDs")

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2007-03-14 04:01:49 UTC (rev 1375)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2007-03-14 04:04:31 UTC (rev 1376)
@@ -54,6 +54,7 @@
 from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource
 from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.customxml import calendarserver_namespace
+from twistedcaldav.ical import allowedComponents
 from twistedcaldav.ical import Component as iComponent
 
 from twistedcaldav.directory.directory import DirectoryService
@@ -139,12 +140,7 @@
     )
 
     supportedCalendarComponentSet = caldavxml.SupportedCalendarComponentSet(
-        caldavxml.CalendarComponent(name="VEVENT"   ),
-        caldavxml.CalendarComponent(name="VTODO"    ),
-        caldavxml.CalendarComponent(name="VTIMEZONE"),
-        caldavxml.CalendarComponent(name="VJOURNAL" ),
-        caldavxml.CalendarComponent(name="VFREEBUSY"),
-        caldavxml.CalendarComponent(name="VAVAILABILITY"),
+        *[caldavxml.CalendarComponent(name=item) for item in allowedComponents]
     )
 
     def readProperty(self, property, request):

Modified: CalendarServer/trunk/twistedcaldav/schedule.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/schedule.py	2007-03-14 04:01:49 UTC (rev 1375)
+++ CalendarServer/trunk/twistedcaldav/schedule.py	2007-03-14 04:04:31 UTC (rev 1376)
@@ -42,6 +42,7 @@
 from twistedcaldav.resource import CalDAVResource
 from twistedcaldav.caldavxml import caldav_namespace, TimeRange
 from twistedcaldav.config import config
+from twistedcaldav.customxml import calendarserver_namespace
 from twistedcaldav.ical import Component
 from twistedcaldav.method import report_common
 from twistedcaldav.method.put_common import storeCalendarObjectResource
@@ -103,6 +104,22 @@
             ),
         )
 
+    def writeProperty(self, property, request):
+        assert isinstance(property, davxml.WebDAVElement)
+
+        # Strictly speaking CS:calendar-availability is a live property in the sense that the
+        # server enforces what can be stored, however it need not actually
+        # exist so we cannot list it in liveProperties on this resource, since its
+        # its presence there means that hasProperty will always return True for it.
+        if property.qname() == (calendarserver_namespace, "calendar-availability"):
+            if not property.valid():
+                raise HTTPError(ErrorResponse(
+                    responsecode.CONFLICT,
+                    (caldav_namespace, "valid-calendar-data")
+                ))
+
+        return super(ScheduleInboxResource, self).writeProperty(property, request)
+
 class ScheduleOutboxResource (CalendarSchedulingCollectionResource):
     """
     CalDAV schedule Outbox resource.
@@ -340,6 +357,18 @@
                     fbinfo = ([], [], [])
                 
                     try:
+                        # Process the availability property from the Inbox.
+                        has_prop = waitForDeferred(inbox.hasProperty((calendarserver_namespace, "calendar-availability"), request))
+                        yield has_prop
+                        has_prop = has_prop.getResult()
+                        if has_prop:
+                            availability = waitForDeferred(inbox.readProperty((calendarserver_namespace, "calendar-availability"), request))
+                            yield availability
+                            availability = availability.getResult()
+                            availability = availability.calendar()
+                            report_common.processAvailabilityFreeBusy(availability, fbinfo, timerange)
+
+                        # Now process free-busy set calendars
                         matchtotal = 0
                         for calURL in fbset:
                             cal = waitForDeferred(request.locateResource(calURL))

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


More information about the calendarserver-changes mailing list