[CalendarServer-changes] [5573] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu May 6 18:48:48 PDT 2010


Revision: 5573
          http://trac.macosforge.org/projects/calendarserver/changeset/5573
Author:   cdaboo at apple.com
Date:     2010-05-06 18:48:46 -0700 (Thu, 06 May 2010)
Log Message:
-----------
DAV:resource-id support on calendars and address books only.

Modified Paths:
--------------
    CalendarServer/trunk/twext/web2/dav/davxml.py
    CalendarServer/trunk/twext/web2/dav/element/__init__.py
    CalendarServer/trunk/twistedcaldav/resource.py

Added Paths:
-----------
    CalendarServer/trunk/twext/web2/dav/element/rfc5842.py

Modified: CalendarServer/trunk/twext/web2/dav/davxml.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/davxml.py	2010-05-07 01:44:51 UTC (rev 5572)
+++ CalendarServer/trunk/twext/web2/dav/davxml.py	2010-05-07 01:48:46 UTC (rev 5573)
@@ -47,6 +47,7 @@
 from twext.web2.dav.element.rfc3253 import *
 from twext.web2.dav.element.rfc3744 import *
 from twext.web2.dav.element.rfc4331 import *
+from twext.web2.dav.element.rfc5842 import *
 from twext.web2.dav.element.extensions import *
 
 #
@@ -59,6 +60,8 @@
 from twext.web2.dav.element import rfc2518 as r1
 from twext.web2.dav.element import rfc3253 as r2
 from twext.web2.dav.element import rfc3744 as r3
+from twext.web2.dav.element import rfc4331 as r4
+from twext.web2.dav.element import rfc5842 as r5
 from twext.web2.dav.element import extensions as e
 
 __all__ = (
@@ -68,6 +71,8 @@
     registerElements(r1) +
     registerElements(r2) +
     registerElements(r3) +
+    registerElements(r4) +
+    registerElements(r5) +
     registerElements(e) +
     [
         "sname2qname",

Modified: CalendarServer/trunk/twext/web2/dav/element/__init__.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/element/__init__.py	2010-05-07 01:44:51 UTC (rev 5572)
+++ CalendarServer/trunk/twext/web2/dav/element/__init__.py	2010-05-07 01:48:46 UTC (rev 5573)
@@ -38,5 +38,6 @@
     "rfc3253",
     "rfc3744",
     "rfc4331",
+    "rfc5842",
     "extensions",
 ]

Added: CalendarServer/trunk/twext/web2/dav/element/rfc5842.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/element/rfc5842.py	                        (rev 0)
+++ CalendarServer/trunk/twext/web2/dav/element/rfc5842.py	2010-05-07 01:48:46 UTC (rev 5573)
@@ -0,0 +1,126 @@
+##
+# Copyright (c) 2005-2007 Apple Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+# DRI: Cyrus Daboo, cdaboo at apple.com
+##
+
+from twext.web2.dav.element.base import WebDAVTextElement, WebDAVElement,\
+    dav_namespace
+
+"""
+RFC 5842 (Binding Extensions to WebDAV) XML Elements
+
+This module provides XML element definitions for use with WebDAV.
+
+See RFC 5842: http://www.ietf.org/rfc/rfc5842.txt
+"""
+
+class ResourceID (WebDAVTextElement):
+    """
+    Unique identifier for a resource
+    """
+    name = "resource-id"
+    hidden = True
+    protected = True
+
+    allowed_children = { (dav_namespace, "href"): (0, 1) }
+
+class ParentSet (WebDAVElement):
+    """
+    Identifies other bindings to a resource
+    """
+    name = "parent-set"
+    hidden = True
+    protected = True
+
+    allowed_children = { (dav_namespace, "parent"): (0, 1) }
+
+class Parent (WebDAVElement):
+
+    name = "parent"
+
+    allowed_children = {
+        (dav_namespace, "href")    : (1, 1),
+        (dav_namespace, "segment") : (1, 1),
+    }
+
+class Segment (WebDAVTextElement):
+
+    name = "segment"
+
+# Problem: DAV:bind is also defined in RFC3744 but with our XML element parsing/mapping behavior
+# we are not allowed to have two class with the same qname(). So we are stuck.
+
+#class BindResponse (WebDAVElement):
+#    """
+#    Response body for a BIND request
+#    """
+#
+#    name = "bind-response"
+#
+#    allowed_children = {
+#        # ANY
+#    }
+#
+#class UnbindRequest (WebDAVElement):
+#    """
+#    Request body for a UNBIND request
+#    """
+#
+#    name = "unbind"
+#
+#    allowed_children = {
+#        (dav_namespace, "segment") : (1, 1),
+#    }
+#
+#class Unbind (WebDAVElement):
+#    """
+#    Response body for a UNBIND request
+#    """
+#
+#    name = "unbind-response"
+#
+#    allowed_children = {
+#        # ANY
+#    }
+#
+#class RebindRequest (WebDAVElement):
+#    """
+#    Request body for a REBIND request
+#    """
+#
+#    name = "rebind"
+#
+#    allowed_children = {
+#        (dav_namespace, "segment") : (1, 1),
+#        (dav_namespace, "href")    : (1, 1),
+#    }
+#
+#class Rebind (WebDAVElement):
+#    """
+#    Response body for a UNBIND request
+#    """
+#
+#    name = "rebind-response"
+#
+#    allowed_children = {
+#        # ANY
+#    }

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2010-05-07 01:44:51 UTC (rev 5572)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2010-05-07 01:48:46 UTC (rev 5573)
@@ -30,6 +30,7 @@
 
 import urllib
 from urlparse import urlsplit
+import uuid
 
 from zope.interface import implements
 
@@ -168,8 +169,14 @@
                 caldavxml.SupportedCalendarData.qname(),
             )
 
+        if self.isCalendarCollection():
+            baseProperties += (
+                davxml.ResourceID.qname(),
+            )
+
         if self.isAddressBookCollection():
             baseProperties += (
+                davxml.ResourceID.qname(),
                 carddavxml.SupportedAddressData.qname(),
             )
 
@@ -301,6 +308,9 @@
             owner = (yield self.owner(request))
             returnValue(davxml.Owner(owner))
 
+        elif qname == davxml.ResourceID.qname():
+            returnValue(davxml.ResourceID(davxml.HRef.fromString(self.resourceID())))
+
         elif qname == davxml.SyncToken.qname() and config.EnableSyncReport and (
             self.isPseudoCalendarCollection() or self.isAddressBookCollection()
         ):
@@ -642,6 +652,12 @@
         else:
             return super(DAVResource, self).displayName()
 
+    def resourceID(self):
+        if not self.hasDeadProperty(davxml.ResourceID.qname()):
+            uuidval = uuid.uuid4()
+            self.writeDeadProperty(davxml.ResourceID(davxml.HRef.fromString(uuidval.urn)))
+        return str(self.readDeadProperty(davxml.ResourceID.qname()).children[0])
+
     ##
     # CalDAV
     ##
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100506/cdedfeee/attachment.html>


More information about the calendarserver-changes mailing list