[CalendarServer-changes] [8239] CalendarServer/branches/users/cdaboo/component-set-fixes

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 31 19:55:21 PDT 2011


Revision: 8239
          http://trac.macosforge.org/projects/calendarserver/changeset/8239
Author:   cdaboo at apple.com
Date:     2011-10-31 19:55:21 -0700 (Mon, 31 Oct 2011)
Log Message:
-----------
Add support for supported-calendar-component-sets and add option to restrict calendars to one component only. Also
simplify the original config design for this feature to just use one option to turn it on.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/caldavxml.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcalendar.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcol.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/resource.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/schedule.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/stdconfig.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/storebridge.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_sharing.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_wrapping.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/file.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/sql.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/test/common.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/util.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/test/util.py
    CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/upgrade/test/test_migrate.py

Added Paths:
-----------
    CalendarServer/branches/users/cdaboo/component-set-fixes/doc/RFC/draft-daboo-caldav-extensions.txt

Added: CalendarServer/branches/users/cdaboo/component-set-fixes/doc/RFC/draft-daboo-caldav-extensions.txt
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/doc/RFC/draft-daboo-caldav-extensions.txt	                        (rev 0)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/doc/RFC/draft-daboo-caldav-extensions.txt	2011-11-01 02:55:21 UTC (rev 8239)
@@ -0,0 +1,672 @@
+
+
+
+Network Working Group                                           C. Daboo
+Internet-Draft                                                     Apple
+Intended status: Standards Track                        October 28, 2011
+Expires: April 30, 2012
+
+
+                     Collected Extensions to CalDAV
+                    draft-daboo-caldav-extensions-01
+
+Abstract
+
+   This document defines a set of extensions to the CalDAV calendar
+   access protocol.
+
+Status of this Memo
+
+   This Internet-Draft is submitted in full conformance with the
+   provisions of BCP 78 and BCP 79.
+
+   Internet-Drafts are working documents of the Internet Engineering
+   Task Force (IETF).  Note that other groups may also distribute
+   working documents as Internet-Drafts.  The list of current Internet-
+   Drafts is at http://datatracker.ietf.org/drafts/current/.
+
+   Internet-Drafts are draft documents valid for a maximum of six months
+   and may be updated, replaced, or obsoleted by other documents at any
+   time.  It is inappropriate to use Internet-Drafts as reference
+   material or to cite them other than as "work in progress."
+
+   This Internet-Draft will expire on April 30, 2012.
+
+Copyright Notice
+
+   Copyright (c) 2011 IETF Trust and the persons identified as the
+   document authors.  All rights reserved.
+
+   This document is subject to BCP 78 and the IETF Trust's Legal
+   Provisions Relating to IETF Documents
+   (http://trustee.ietf.org/license-info) in effect on the date of
+   publication of this document.  Please review these documents
+   carefully, as they describe your rights and restrictions with respect
+   to this document.  Code Components extracted from this document must
+   include Simplified BSD License text as described in Section 4.e of
+   the Trust Legal Provisions and are provided without warranty as
+   described in the Simplified BSD License.
+
+
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 1]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+Table of Contents
+
+   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  3
+   2.  Conventions Used in This Document  . . . . . . . . . . . . . .  3
+   3.  Extended Calendar Query Report . . . . . . . . . . . . . . . .  3
+     3.1.  CALDAV:comp-filter XML Element . . . . . . . . . . . . . .  4
+     3.2.  CALDAV:prop-filter XML Element . . . . . . . . . . . . . .  5
+     3.3.  CALDAV:text-match XML Element  . . . . . . . . . . . . . .  5
+     3.4.  Examples . . . . . . . . . . . . . . . . . . . . . . . . .  6
+   4.  Advertising Supported Calendar Component Sets  . . . . . . . .  7
+     4.1.  CALDAV:supported-calendar-component-sets Property  . . . .  8
+   5.  Filtering by Calendar Component Type . . . . . . . . . . . . .  9
+   6.  Security Considerations  . . . . . . . . . . . . . . . . . . . 10
+   7.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 10
+   8.  Acknowledgments  . . . . . . . . . . . . . . . . . . . . . . . 10
+   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 11
+     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 11
+     9.2.  Informative References . . . . . . . . . . . . . . . . . . 11
+   Appendix A.  Change History (To be removed by RFC Editor
+                before publication) . . . . . . . . . . . . . . . . . 11
+   Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 2]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+1.  Introduction
+
+   [RFC4791] defines the CalDAV Calendar Access protocol for accessing
+   calendar data stored on a server.  With the popularity of CalDAV
+   increasing, a number of useful extensions have been proposed to
+   improve the protocol.  This specification collects several of those
+   extensions into one document for convenience.  Each extension defined
+   in this specification can be implemented independently of any of the
+   others.
+
+   Discussion of this Internet-Draft is taking place on the mailing list
+   <https://www.ietf.org/mailman/listinfo/caldav>.
+
+
+2.  Conventions Used in This Document
+
+   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
+   "OPTIONAL" in this document are to be interpreted as described in
+   [RFC2119].
+
+   Other notations used in this memo follow the notations of [RFC4791].
+
+
+3.  Extended Calendar Query Report
+
+   The CALDAV:calendar-query report defined in Section 7.8 of [RFC4791]
+   allows a client to search calendar data for a match to iCalendar
+   component, property or parameter details.  As defined, this option
+   supports querying multiple attributes of the iCalendar data at
+   various "nesting" levels based on the syntactic structure of
+   iCalendar itself.  When multiple attributes are queried at the same
+   level, each has to match for the query to be successful - effectively
+   defining a logical "and" operation.  This does not allow clients to
+   execute a single query to match different attributes of different
+   component types (e.g., clients cannot search for VEVENTs with a
+   particular time-range, or VTODOs that are not completed).  Since
+   there is a need to be able to execute such queries, a logical "or"
+   operation is needed.
+
+   This specification adds a "test" XML attribute to the CALDAV:comp-
+   filter and CALDAV:prop-filter XML elements that accepts values of
+   "allof" or "anyof" to indicate logical "and" or "or" operations
+   respectively.  This copies the behavior defined for CARDDAV:
+   addressbook-query reports defined in Section 10.5 of [RFC6352], with
+   the exception that the default value for the attribute is "allof" to
+   match the current behavior.
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 3]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   The text comparison operation in [RFC4791] is a simple "contains"
+   operation, however more sophisticated comparisons are sometimes
+   needed (e.g., 'starts with', 'equals', etc).
+
+   This specification adds a "match-type" XML attribute to the CALDAV:
+   text-match XML element that accepts values of "equals", "contains",
+   "starts-with", or "ends-with", to indicate the comparison operation
+   to be used.  This copies the behavior defined for CARDDAV:
+   addressbook-query reports defined in Section 10.5.4 of [RFC6352].
+
+   Sometimes clients want to search all component types for a match
+   (e.g., clients cannot find all calendar object resources that contain
+   a SUMMARY property value matching some text irrespective of the top-
+   level component type).
+
+   This specification allows the use of a single "*" character in the
+   "name" attribute of "comp-filter" elements to require the server to
+   match any component type.
+
+   Servers advertise support for this extension by including the token
+   "calendar-query-extended" in the DAV response header to an OPTIONS
+   request on any resource supporting the extended query report.
+   Clients MUST check for the presence of that token before using the
+   "test" or "match-type" XML attributes.
+
+   This specification extends the [RFC4791] XML syntax for the CALDAV:
+   comp-filter, CALDAV:prop-filter and CALDAV:text-match XML elements as
+   follows.
+
+3.1.  CALDAV:comp-filter XML Element
+
+   XML Element:  CALDAV:comp-filter
+
+   Updated Definition:
+
+   <!ELEMENT comp-filter (is-not-defined | (time-range?,
+                          prop-filter*, comp-filter*))>
+
+   <!ATTLIST comp-filter name CDATA #REQUIRED
+                         test (allof | anyof) "allof">
+   <!-- name value:
+           a calendar object or calendar component type (e.g., VEVENT),
+           or the value "*" to indicate a match against any type
+
+        test value:
+           allof logical AND for matches
+           anyof logical OR for matches
+    -->
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 4]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   Additional Description:  The "test" attribute specifies whether any
+      (logical OR) or all (logical AND) of the is-not-defined, time-
+      range, comp-filter or param-filter tests need to match in order
+      for the overall filter to match.
+
+3.2.  CALDAV:prop-filter XML Element
+
+   XML Element:  CALDAV:prop-filter
+
+   Updated Definition:
+
+   <!ELEMENT prop-filter (is-not-defined |
+                          ((time-range | text-match)?,
+                           param-filter*))>
+
+   <!ATTLIST prop-filter name CDATA #REQUIRED
+                         test (allof | anyof) "allof">
+   <!-- name value:
+           a calendar property name (e.g., ATTENDEE)
+
+        test value:
+           allof logical AND for matches
+           anyof logical OR for matches
+    -->
+
+   Additional Description:  The "test" attribute specifies whether any
+      (logical OR) or all (logical AND) of the is-not-defined, time-
+      range, text-filter or param-filter tests need to match in order
+      for the overall filter to match.
+
+3.3.  CALDAV:text-match XML Element
+
+   XML Element:  CALDAV:text-match
+
+   Updated Definition:
+
+   <!ELEMENT text-match (#PCDATA)>
+   <!-- PCDATA value: string -->
+
+   <!ATTLIST text-match
+       collation        CDATA "i;ascii-casemap"
+       negate-condition (yes | no) "no"
+       match-type (equals|contains|starts-with|ends-with) "contains">
+
+   Additional Description:  The "match-type" attribute is used to
+      indicate the type of match operation to use.  Possible choices
+      are:
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 5]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+         "equals" - an exact match to the target string
+
+         "contains" - a substring match, matching anywhere within the
+         target string
+
+         "starts-with" - a substring match, matching only at the start
+         of the target string
+
+         "ends-with" - a substring match, matching only at the end of
+         the target string
+
+3.4.  Examples
+
+   In this request, the client is querying for VEVENTs that start on or
+   after a specific date, or VTODOs that are not completed and not
+   cancelled.
+
+   REPORT /bernard/work/ HTTP/1.1
+   Host: cal.example.com
+   Depth: 1
+   Content-Type: application/xml; charset="utf-8"
+   Content-Length: xxxx
+
+   <?xml version="1.0" encoding="utf-8" ?>
+   <C:calendar-query xmlns:D="DAV:"
+                 xmlns:C="urn:ietf:params:xml:ns:caldav">
+     <D:prop>
+       <D:getetag/>
+     </D:prop>
+     <C:filter>
+       <C:comp-filter name="VCALENDAR" test="anyof">
+         <C:comp-filter name="VEVENT">
+           <C:time-range start="20110101T000000Z"/>
+         </C:comp-filter>
+         <C:comp-filter name="VTODO" test="allof">
+           <C:prop-filter name="COMPLETED">
+             <C:is-not-defined/>
+           </C:prop-filter>
+           <C:prop-filter name="STATUS">
+             <C:text-match
+                negate-condition="yes"
+                match-type="equals">CANCELLED</C:text-match>
+           </C:prop-filter>
+         </C:comp-filter>
+       </C:comp-filter>
+     </C:filter>
+   </C:calendar-query>
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 6]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   In this request, the client is querying for any component that
+   contains a VALARM sub-component.
+
+   REPORT /bernard/work/ HTTP/1.1
+   Host: cal.example.com
+   Depth: 1
+   Content-Type: application/xml; charset="utf-8"
+   Content-Length: xxxx
+
+   <?xml version="1.0" encoding="utf-8" ?>
+   <C:calendar-query xmlns:D="DAV:"
+                 xmlns:C="urn:ietf:params:xml:ns:caldav">
+     <D:prop>
+       <D:getetag/>
+     </D:prop>
+     <C:filter>
+       <C:comp-filter name="VCALENDAR">
+         <C:comp-filter name="*">
+           <C:comp-filter name="VALARM" />
+         </C:comp-filter>
+       </C:comp-filter>
+     </C:filter>
+   </C:calendar-query>
+
+
+4.  Advertising Supported Calendar Component Sets
+
+   CalDAV [RFC4791] supports the notion of calendar collections that are
+   restricted to only containing components of a certain type, or set of
+   types.  The protocol allows clients to specify the restricted
+   component sets by supplying a CALDAV:supported-calendar-component-set
+   WebDAV property in an MKCALENDAR or extended MKCOL [RFC5689] request
+   that creates a calendar collection.  However, servers themselves
+   might need to restrict the allowed sets of components that can be
+   used in any one calendar (e.g., some servers might only support
+   calendar collections containing components of one type).  Currently
+   there is no way for a client to determine what the allowed
+   combination of component types is for use with MKCALENDAR or extended
+   MKCOL.
+
+   This specification adds a new CALDAV:supported-calendar-component-
+   sets WebDAV property for use on calendar home collections.  This
+   property enumerates the allowed sets of calendar components that the
+   server will support for use with MKCALENDAR or extended MKCOL
+   requests.  Clients SHOULD check for the presence of this property
+   before issuing an MKCALENDAR or extended MKCOL request that includes
+   a CALDAV:supported-calendar-component-set WebDAV property.  When the
+   new property is found on a calendar home, clients MUST only use a
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 7]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   CALDAV:supported-calendar-component-set is one advertised as being
+   supported.
+
+4.1.  CALDAV:supported-calendar-component-sets Property
+
+   Name:  supported-calendar-component-sets
+
+   Namespace:  urn:ietf:params:xml:ns:caldav
+
+   Purpose:  Enumerates the sets of component restrictions the server is
+      willing to allow the client to specify in MKCALENDAR or extended
+      MKCOL requests.
+
+   Protected:  This property MUST be protected and SHOULD NOT be
+      returned by a PROPFIND allprop request (as defined in Section 14.2
+      of [RFC4918]).
+
+   COPY/MOVE behavior:  This property value MUST be preserved in COPY
+      and MOVE operations.
+
+   Description:  If servers apply restrictions on the allowed calendar
+      component sets used when creating a calendar, then those servers
+      SHOULD advertise this property on each calendar home collection
+      within which the restrictions apply.  In the absence of this
+      property, clients cannot assume anything about whether the server
+      will enforce a set of restrictions or not - in that case clients
+      need to handle the server rejecting certain combinations of
+      restricted component sets.  If this property is present, but
+      contains no child XML elements, then clients can assume that the
+      server imposes no restrictions on the combinations of component
+      types it is willing to accept.  If present, each CALDAV:supported-
+      calendar-component-set element represents a valid restriction the
+      client can use in an MKCALENDAR or extended MKCOL request when
+      creating a calendar.
+
+   Definition:
+
+      <!ELEMENT supported-calendar-component-sets
+                (supported-calendar-component-set*) >
+      <!-- supported-calendar-component-set defined in RFC4791 -->
+
+   Example:
+
+
+
+
+
+
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 8]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   <C:supported-calendar-component-sets
+        xmlns:C="urn:ietf:params:xml:ns:caldav">
+
+     <!-- Calendars with any standard iCalendar component -->
+     <C:supported-calendar-component-set>
+       <C:comp name="VEVENT" />
+       <C:comp name="VFREEBUSY" />
+       <C:comp name="VJOURNAL" />
+       <C:comp name="VTODO" />
+     </C:supported-calendar-component-set>
+
+     <!-- Calendars with just VEVENT or VFREEBUSY -->
+     <C:supported-calendar-component-set>
+       <C:comp name="VEVENT" />
+       <C:comp name="VFREEBUSY" />
+     </C:supported-calendar-component-set>
+
+     <!-- Calendars with just VEVENT -->
+     <C:supported-calendar-component-set>
+       <C:comp name="VEVENT" />
+     </C:supported-calendar-component-set>
+
+     <!-- Calendars with just VTODO -->
+     <C:supported-calendar-component-set>
+       <C:comp name="VTODO" />
+     </C:supported-calendar-component-set>
+   </C:supported-calendar-component-sets>
+
+
+5.  Filtering by Calendar Component Type
+
+   Calendar clients are sometimes "scoped" to only utilize one type of
+   main calendar component type (e.g., a scheduling client that only
+   handles "VEVENT" components, or a task manager that only handles
+   "VTODO" components).  CalDAV provides a calendar query report that
+   allows clients to find only calendar object resources that contain a
+   specified main component type, which is useful when initially loading
+   the contents of a calendar into a local cache.  However, clients also
+   need to keep that cache updated as changes occur on the server.  One
+   way to do that is to use the WebDAV sync report
+   [I-D.daboo-webdav-sync], but that report will return changes for all
+   calendar object resources within a calendar collection.  Thus
+   "scoped" clients will be forced to load calendar object resources
+   containing component types they do not care about to discover what
+   type they are, or issue additional queries to see whether the changes
+   reported by the sync report are for component types it handles.  A
+   better approach would be to have a way for the WebDAV sync report
+   response to include details of the calendar component type for each
+
+
+
+Daboo                    Expires April 30, 2012                 [Page 9]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+   calendar object resource that it reports as changed.
+
+   To better "scope" a WebDAV sync report, this specification recommends
+   that servers SHOULD always include a "component=" parameter (as
+   defined in Section 8.1 of [RFC5545]) in the DAV:getcontenttype WebDAV
+   property media-type value reported for calendar object resources.
+   Clients can then request that property be returned in the WebDAV sync
+   report response for each resource, and thus quickly determine which
+   changes are relevant to them based on component type.
+
+   Example partial WebDAV sync report response with a component type
+   included.
+
+   <D:response>
+     <D:href
+   >http://calendar.example.com/cyrusdaboo/calendar.ics</D:href>
+     <D:propstat>
+       <D:prop>
+         <D:getetag>"00003-abcd1"</D:getetag>
+         <D:getcontenttype
+         >text/calendar;charset=utf-8;component=vevent<
+         /D:getcontenttype>
+       </D:prop>
+       <D:status>HTTP/1.1 200 OK</D:status>
+     </D:propstat>
+    </D:response>
+
+
+6.  Security Considerations
+
+   This specification does not introduce any new security concerns
+   beyond those addressed in CalDAV [RFC4791] and iCalendar [RFC5545].
+
+
+7.  IANA Considerations
+
+   No IANA actions are needed.
+
+
+8.  Acknowledgments
+
+   Thanks to Bernard Desruisseaux, Mike Douglass, Jeffrey Harris, Arnaud
+   Quillaud, and Nick Zitzmann.  This specification came about via
+   discussions at the Calendaring and Scheduling Consortium.
+
+
+9.  References
+
+
+
+
+Daboo                    Expires April 30, 2012                [Page 10]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+9.1.  Normative References
+
+   [I-D.daboo-webdav-sync]
+              Daboo, C. and A. Quillaud, "Collection Synchronization for
+              WebDAV", draft-daboo-webdav-sync-06 (work in progress),
+              July 2011.
+
+   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
+              Requirement Levels", BCP 14, RFC 2119, March 1997.
+
+   [RFC4791]  Daboo, C., Desruisseaux, B., and L. Dusseault,
+              "Calendaring Extensions to WebDAV (CalDAV)", RFC 4791,
+              March 2007.
+
+   [RFC4918]  Dusseault, L., "HTTP Extensions for Web Distributed
+              Authoring and Versioning (WebDAV)", RFC 4918, June 2007.
+
+   [RFC5545]  Desruisseaux, B., "Internet Calendaring and Scheduling
+              Core Object Specification (iCalendar)", RFC 5545,
+              September 2009.
+
+   [RFC5689]  Daboo, C., "Extended MKCOL for Web Distributed Authoring
+              and Versioning (WebDAV)", RFC 5689, September 2009.
+
+9.2.  Informative References
+
+   [RFC6352]  Daboo, C., "CardDAV: vCard Extensions to Web Distributed
+              Authoring and Versioning (WebDAV)", RFC 6352, August 2011.
+
+
+Appendix A.  Change History (To be removed by RFC Editor before
+             publication)
+
+   Changes in -01:
+
+   1.  Changed description of COPY/MOVE for supported-calendar-
+       component-sets property
+
+   2.  Removed bogus text in property description.
+
+   3.  Changed supported-calendar-component-sets to use supported-
+       calendar-component-set as a child element.
+
+   4.  Added recommendation to use "component=" parameter in DAV:
+       getcontenttype WebDAV properties on calendar object resources.
+
+
+
+
+
+
+Daboo                    Expires April 30, 2012                [Page 11]
+
+Internet-Draft              CalDAV Extensions               October 2011
+
+
+Author's Address
+
+   Cyrus Daboo
+   Apple Inc.
+   1 Infinite Loop
+   Cupertino, CA  95014
+   USA
+
+   Email: cyrus at daboo.name
+   URI:   http://www.apple.com/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Daboo                    Expires April 30, 2012                [Page 12]
+

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/caldavxml.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/caldavxml.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/caldavxml.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -188,10 +188,21 @@
     name = "calendar-timezone"
     hidden = True
 
+class SupportedCalendarComponentSets (CalDAVElement):
+    """
+    Indicates what set of calendar components the server is willing to allow
+    the client to use in MKCALENDAR.
+    (CalDAV-extensions, draft-daboo-caldav-extensions section XXX)
+    """
+    name = "supported-calendar-component-sets"
+    hidden = True
+    protected = True
+
+    allowed_children = { (caldav_namespace, "supported-calendar-component-set"): (0, None) }
+
 class SupportedCalendarComponentSet (CalDAVElement):
     """
-    Provides a human-readable description of what this calendar collection
-    represents.
+    Indicates what set of calendar components are allowed in a collection.
     (CalDAV-access, RFC 4791 section 5.2.3)
     """
     name = "supported-calendar-component-set"

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcalendar.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcalendar.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcalendar.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -111,7 +111,7 @@
             raise HTTPError(MultiStatusResponse([errors.response()]))
         
     # When calendar collections are single component only, default MKCALENDAR is VEVENT only
-    if not set_supported_component_set and config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
+    if not set_supported_component_set and config.RestrictCalendarsToOneComponentType:
         yield self.setSupportedComponents(("VEVENT",))
             
 

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcol.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcol.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/method/mkcol.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -182,12 +182,12 @@
             self.transactionError()
             errors.error()
             raise HTTPError(Response(
-                    code=responsecode.BAD_REQUEST,
+                    code=responsecode.FORBIDDEN,
                     stream=mkcolxml.MakeCollectionResponse(errors.response()).toxml()
             ))
         
         # When calendar collections are single component only, default MKCALENDAR is VEVENT only
-        if rtype == "calendar" and not set_supported_component_set and config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
+        if rtype == "calendar" and not set_supported_component_set and config.RestrictCalendarsToOneComponentType:
             yield self.setSupportedComponents(("VEVENT",))
 
         yield returnValue(responsecode.CREATED)

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/resource.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/resource.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -2384,6 +2384,45 @@
         returnValue((storeHome, created))
 
 
+    def liveProperties(self):
+        
+        existing = super(CalendarHomeResource, self).liveProperties()
+        existing += (caldavxml.SupportedCalendarComponentSets.qname(),)
+        existing += (
+            (customxml.calendarserver_namespace, "xmpp-uri"),
+            (customxml.calendarserver_namespace, "xmpp-heartbeat-uri"),
+            (customxml.calendarserver_namespace, "xmpp-server"),
+        )
+        return existing
+
+    @inlineCallbacks
+    def readProperty(self, property, request):
+        if type(property) is tuple:
+            qname = property
+        else:
+            qname = property.qname()
+
+        if qname == caldavxml.SupportedCalendarComponentSets.qname():
+            if config.RestrictCalendarsToOneComponentType:
+                prop = caldavxml.SupportedCalendarComponentSets(
+                    caldavxml.SupportedCalendarComponentSet(
+                        caldavxml.CalendarComponent(
+                            name="VEVENT",
+                        ),
+                    ),
+                    caldavxml.SupportedCalendarComponentSet(
+                        caldavxml.CalendarComponent(
+                            name="VTODO",
+                        ),
+                    ),
+                )
+            else:
+                prop = caldavxml.SupportedCalendarComponentSets()
+            returnValue(prop)
+            
+        result = (yield super(CalendarHomeResource, self).readProperty(property, request))
+        returnValue(result)
+
     def _setupProvisions(self):
 
         # Cache children which must be of a specific type
@@ -2412,7 +2451,7 @@
         # this URL live from a back-end method that tells us what the
         # default calendar is.
         inbox = yield self.getChild("inbox")
-        childURL = joinURL(self.url(), config.CalDAV.AccountProvisioning.CalendarName)
+        childURL = joinURL(self.url(), "calendar")
         inbox.processFreeBusyCalendar(childURL, True)
 
 
@@ -2548,14 +2587,6 @@
         returnValue((changed, deleted, notallowed))
 
 
-    def liveProperties(self):
-
-        return super(CalendarHomeResource, self).liveProperties() + (
-            (customxml.calendarserver_namespace, "xmpp-uri"),
-            (customxml.calendarserver_namespace, "xmpp-heartbeat-uri"),
-            (customxml.calendarserver_namespace, "xmpp-server"),
-        )
-
 class AddressBookHomeResource (CommonHomeResource):
     """
     Address book home collection resource.

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/schedule.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/schedule.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/schedule.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -289,7 +289,7 @@
         """
         
         componentType = "VTODO" if tasks else "VEVENT"
-        test_name = config.CalDAV.AccountProvisioning.TasksName if tasks else config.CalDAV.AccountProvisioning.CalendarName
+        test_name = "tasks" if tasks else "calendar"
         prop_to_set = customxml.ScheduleDefaultTasksURL if tasks else caldavxml.ScheduleDefaultCalendarURL
 
         calendarHomeURL = self.parent.url()

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/stdconfig.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/stdconfig.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -521,15 +521,11 @@
         }        
     },
     
-    "CalDAV": {
-        "AccountProvisioning": {
-            "CalendarName":                "calendar",  # Name to use when provisioning calendar for VEVENTs only, or
-                                                        # VEVENTs and VTODOs if KeepComponentTypesSeparate is False
-            "TasksName":                   "tasks",     # Name to use when provisioning calendar for VTODOs only, not
-                                                        # provisioned if KeepComponentTypesSeparate is False
-            "KeepComponentTypesSeparate" : True,        # Provision collections with separate component types
-        },
-    },
+    "RestrictCalendarsToOneComponentType" : True,  # Only allow calendars to be created with a single component type
+                                                   # If this is on, it will also trigger an upgrade behavior that will
+                                                   # split existing calendars into multiples based on component type.
+                                                   # If on, it will also cause new accounts to provision with separate
+                                                   # calendars for events and tasks.
 
     # CardDAV Features
     "DirectoryAddressBook": {

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/storebridge.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/storebridge.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -900,8 +900,8 @@
         """
         Parse out XML property into list of components and give to store.
         """
-        support_components = ",".join(sorted([comp.attributes["name"].upper() for comp in support_components_property.children]))
-        return maybeDeferred(self._newStoreObject.setSupportedComponents, support_components)
+        support_components = tuple([comp.attributes["name"].upper() for comp in support_components_property.children])
+        return self.setSupportedComponents(support_components)
     
     def getSupportedComponentSet(self):
         comps = self._newStoreObject.getSupportedComponents()
@@ -920,6 +920,11 @@
         @param components: list of names of components to support
         @type components: C{list}
         """
+        
+        # Validate them first - raise on failure
+        if not self.validSupportedComponents(components):
+            raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Invalid CALDAV:supported-calendar-component-set"))
+
         support_components = ",".join(sorted([comp.upper() for comp in components]))
         return maybeDeferred(self._newStoreObject.setSupportedComponents, support_components)
     
@@ -934,6 +939,15 @@
     def isSupportedComponent(self, componentType):
         return self._newStoreObject.isSupportedComponent(componentType)
 
+    def validSupportedComponents(self, components):
+        """
+        Test whether the supplied set of components is valid for the current server's component set
+        restrictions.
+        """
+        if config.RestrictCalendarsToOneComponentType:
+            return components in (("VEVENT",), ("VTODO",),)
+        return True
+
     
 class CalendarCollectionResource(_CalendarCollectionBehaviorMixin, _CommonHomeChildCollectionMixin, CalDAVResource):
     """

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_sharing.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_sharing.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -85,7 +85,7 @@
             request = norequest()
         result = yield super(SharingTests, self)._refreshRoot(request)
         self.resource = (
-            yield self.site.resource.locateChild(request, [config.CalDAV.AccountProvisioning.CalendarName])
+            yield self.site.resource.locateChild(request, ["calendar"])
         )[0]
         returnValue(result)
 

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_wrapping.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/twistedcaldav/test/test_wrapping.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -121,7 +121,7 @@
             pass
         txn = self.calendarCollection._newStore.newTransaction()
         home = yield txn.calendarHomeWithUID(uid, True)
-        cal = yield home.calendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
+        cal = yield home.calendarWithName("calendar")
         yield cal.createCalendarObjectWithName(
             objectName, VComponent.fromString(objectText)
         )

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/file.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/file.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -184,16 +184,16 @@
     def createdHome(self):
 
         # Default calendar
-        defaultCal = self.createCalendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
+        defaultCal = self.createCalendarWithName("calendar")
         props = defaultCal.properties()
         props[PropertyName(*ScheduleCalendarTransp.qname())] = ScheduleCalendarTransp(Opaque())
         
         # Check whether components type must be separate
-        if config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
+        if config.RestrictCalendarsToOneComponentType:
             defaultCal.setSupportedComponents("VEVENT")
             
             # Default tasks
-            defaultTasks = self.createCalendarWithName(config.CalDAV.AccountProvisioning.TasksName)
+            defaultTasks = self.createCalendarWithName("tasks")
             props = defaultTasks.properties()
             defaultTasks.setSupportedComponents("VTODO")
             

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/sql.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/sql.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -213,16 +213,16 @@
     def createdHome(self):
         
         # Default calendar
-        defaultCal = yield self.createCalendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
+        defaultCal = yield self.createCalendarWithName("calendar")
         props = defaultCal.properties()
         props[PropertyName(*ScheduleCalendarTransp.qname())] = ScheduleCalendarTransp(Opaque())
         
         # Check whether components type must be separate
-        if config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
+        if config.RestrictCalendarsToOneComponentType:
             defaultCal.setSupportedComponents("VEVENT")
             
             # Default tasks
-            defaultTasks = yield self.createCalendarWithName(config.CalDAV.AccountProvisioning.TasksName)
+            defaultTasks = yield self.createCalendarWithName("tasks")
             defaultTasks.setSupportedComponents("VTODO")
             
         yield self.createCalendarWithName("inbox")

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/test/common.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/test/common.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -541,22 +541,22 @@
         L{ICalendarHome.createdHome} creates a calendar only, or a calendar and tasks
         collection only, in addition to inbox.
         """
-        self.patch(config.CalDAV.AccountProvisioning, "KeepComponentTypesSeparate", False)
+        self.patch(config, "RestrictCalendarsToOneComponentType", False)
         home1 = yield self.transactionUnderTest().calendarHomeWithUID("home_provision1", create=True)
-        for name in (config.CalDAV.AccountProvisioning.CalendarName, "inbox",):
+        for name in ("calendar", "inbox",):
             calendar = yield home1.calendarWithName(name)
             if calendar is None:
                 self.fail("calendar %r didn't exist" % (name,))
             self.assertProvides(ICalendar, calendar)
             self.assertEquals(calendar.name(), name)
-        for name in (config.CalDAV.AccountProvisioning.TasksName,):
+        for name in ("tasks",):
             calendar = yield home1.calendarWithName(name)
             if calendar is not None:
                 self.fail("calendar %r exists" % (name,))
 
-        self.patch(config.CalDAV.AccountProvisioning, "KeepComponentTypesSeparate", True)
+        self.patch(config, "RestrictCalendarsToOneComponentType", True)
         home2 = yield self.transactionUnderTest().calendarHomeWithUID("home_provision2", create=True)
-        for name in (config.CalDAV.AccountProvisioning.CalendarName, config.CalDAV.AccountProvisioning.TasksName, "inbox",):
+        for name in ("calendar", "tasks", "inbox",):
             calendar = yield home2.calendarWithName(name)
             if calendar is None:
                 self.fail("calendar %r didn't exist" % (name,))
@@ -1315,7 +1315,7 @@
         self.assertProvides(ICalendarHome, calendarHome)
         # Default calendar should be automatically created.
         self.assertProvides(ICalendar,
-                            (yield calendarHome.calendarWithName(config.CalDAV.AccountProvisioning.CalendarName)))
+                            (yield calendarHome.calendarWithName("calendar")))
         # A concurrent transaction shouldn't be able to read it yet:
         self.assertIdentical((yield readOtherTxn()), None)
         yield self.commit()
@@ -1936,9 +1936,9 @@
         home2 = yield self.transactionUnderTest().calendarHomeWithUID(
             "home2", create=True)
         calendar1 = yield home1.calendarWithName("calendar_1")
-        calendar2 = yield home2.calendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
+        calendar2 = yield home2.calendarWithName("calendar")
         objects = list(
-            (yield (yield home2.calendarWithName(config.CalDAV.AccountProvisioning.CalendarName)).calendarObjects()))
+            (yield (yield home2.calendarWithName("calendar")).calendarObjects()))
         self.assertEquals(objects, [])
         for resourceName in self.requirements['home1']['calendar_1'].keys():
             obj = yield calendar1.calendarObjectWithName(resourceName)

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/util.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/caldav/datastore/util.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -277,9 +277,9 @@
         (from a calendar in C{inHome}) and returns a L{VComponent} (to store in
         a calendar in outHome).
     """
-    yield outHome.removeCalendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
-    if config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
-        yield outHome.removeCalendarWithName(config.CalDAV.AccountProvisioning.TasksName)
+    yield outHome.removeCalendarWithName("calendar")
+    if config.RestrictCalendarsToOneComponentType:
+        yield outHome.removeCalendarWithName("tasks")
     yield outHome.removeCalendarWithName("inbox")
     outHome.properties().update(inHome.properties())
     inCalendars = yield inHome.calendars()

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/test/util.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/test/util.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -261,9 +261,9 @@
             # We don't want the default calendar or inbox to appear unless it's
             # explicitly listed.
             try:
-                yield home.removeCalendarWithName(config.CalDAV.AccountProvisioning.CalendarName)
-                if config.CalDAV.AccountProvisioning.KeepComponentTypesSeparate:
-                    yield home.removeCalendarWithName(config.CalDAV.AccountProvisioning.TasksName)
+                yield home.removeCalendarWithName("calendar")
+                if config.RestrictCalendarsToOneComponentType:
+                    yield home.removeCalendarWithName("tasks")
                 yield home.removeCalendarWithName("inbox")
             except NoSuchHomeChildError:
                 pass

Modified: CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/upgrade/test/test_migrate.py
===================================================================
--- CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/upgrade/test/test_migrate.py	2011-11-01 02:50:11 UTC (rev 8238)
+++ CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/upgrade/test/test_migrate.py	2011-11-01 02:55:21 UTC (rev 8239)
@@ -130,7 +130,7 @@
         self.addCleanup(vrfyTxn.commit)
         home = yield vrfyTxn.calendarHomeWithUID("home1")
         # The default calendar is still there.
-        self.assertNotIdentical(None, (yield home.calendarWithName(config.CalDAV.AccountProvisioning.CalendarName)))
+        self.assertNotIdentical(None, (yield home.calendarWithName("calendar")))
         # The migrated calendar isn't.
         self.assertIdentical(None, (yield home.calendarWithName("calendar_1")))
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111031/fec86d85/attachment-0001.html>


More information about the calendarserver-changes mailing list