[CalendarServer-changes] [878] CalendarServer/branches/users/cdaboo/cuproxy-857

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 20 23:04:38 PST 2006


Revision: 878
          http://trac.macosforge.org/projects/calendarserver/changeset/878
Author:   cdaboo at apple.com
Date:     2006-12-20 23:04:38 -0800 (Wed, 20 Dec 2006)

Log Message:
-----------
Make sure DAVPrincipalResource behaves like our extended DAVFile when it comes to resourcetype.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/cuproxy-857/lib-patches/Twisted/twisted.web2.dav.resource.patch
    CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/extensions.py
    CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/resource.py

Modified: CalendarServer/branches/users/cdaboo/cuproxy-857/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/branches/users/cdaboo/cuproxy-857/lib-patches/Twisted/twisted.web2.dav.resource.patch	2006-12-21 07:02:09 UTC (rev 877)
+++ CalendarServer/branches/users/cdaboo/cuproxy-857/lib-patches/Twisted/twisted.web2.dav.resource.patch	2006-12-21 07:04:38 UTC (rev 878)
@@ -823,7 +823,7 @@
      # HTTP
      ##
  
-@@ -1558,7 +1913,7 @@
+@@ -1558,10 +1913,10 @@
      """
      DAV resource with no children.
      """
@@ -831,8 +831,31 @@
 +    def findChildren(self, depth, request, callback, privileges=None, inherited_aces=None):
          return succeed(None)
  
- class DAVPrincipalResource (DAVLeafResource):
-@@ -1673,6 +2028,24 @@
+-class DAVPrincipalResource (DAVLeafResource):
++class DAVPrincipalResource (DAVResource):
+     """
+     Resource representing a WebDAV principal.  (RFC 3744, section 2)
+     """
+@@ -1571,7 +1926,7 @@
+     # WebDAV
+     ##
+ 
+-    liveProperties = DAVLeafResource.liveProperties + (
++    liveProperties = DAVResource.liveProperties + (
+         (dav_namespace, "alternate-URI-set"),
+         (dav_namespace, "principal-URL"    ),
+         (dav_namespace, "group-member-set" ),
+@@ -1584,9 +1939,6 @@
+     def isCollection(self):
+         return False
+ 
+-    def findChildren(self, depth, request, callback, privileges=None, inherited_aces=None):
+-        return succeed(None)
+-
+     def readProperty(self, property, request):
+         def defer():
+             if type(property) is tuple:
+@@ -1673,6 +2025,24 @@
          else:
              return uri in self.groupMembers()
  
@@ -857,7 +880,7 @@
  class AccessDeniedError(Exception):
      def __init__(self, errors):
          """ 
-@@ -1712,6 +2085,37 @@
+@@ -1712,6 +2082,37 @@
  davxml.registerElement(TwistedACLInheritable)
  davxml.ACE.allowed_children[(twisted_dav_namespace, "inheritable")] = (0, 1)
  

Modified: CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/extensions.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/extensions.py	2006-12-21 07:02:09 UTC (rev 877)
+++ CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/extensions.py	2006-12-21 07:04:38 UTC (rev 878)
@@ -40,12 +40,37 @@
 from twisted.web2.dav.http import StatusResponse
 from twisted.web2.dav.static import DAVFile as SuperDAVFile
 from twisted.web2.dav.resource import DAVResource as SuperDAVResource
+from twisted.web2.dav.resource import DAVPrincipalResource as SuperDAVPrincipalResource
 
 class DAVResource (SuperDAVResource):
     """
     Extended L{twisted.web2.dav.resource.DAVResource} implementation.
     """
 
+class DAVPrincipalResource (SuperDAVPrincipalResource):
+    """
+    Extended L{twisted.web2.dav.static.DAVFile} implementation.
+    """
+    def readProperty(self, property, request):
+        if type(property) is tuple:
+            qname = property
+        else:
+            qname = property.qname()
+
+        if qname == (dav_namespace, "resourcetype"):
+            return succeed(self.resourceType())
+
+        return super(DAVPrincipalResource, self).readProperty(property, request)
+
+    def resourceType(self):
+        # Allow live property to be overriden by dead property
+        if self.deadProperties().contains((dav_namespace, "resourcetype")):
+            return self.deadProperties().get((dav_namespace, "resourcetype"))
+        if self.isCollection():
+            return davxml.ResourceType(davxml.Collection(), davxml.Principal())
+        else:
+            return davxml.ResourceType(davxml.Principal())
+
 class DAVFile (SuperDAVFile):
     """
     Extended L{twisted.web2.dav.static.DAVFile} implementation.

Modified: CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/resource.py	2006-12-21 07:02:09 UTC (rev 877)
+++ CalendarServer/branches/users/cdaboo/cuproxy-857/twistedcaldav/resource.py	2006-12-21 07:04:38 UTC (rev 878)
@@ -37,7 +37,7 @@
 from twisted.web2 import responsecode
 from twisted.web2.dav import davxml
 from twisted.web2.dav.idav import IDAVPrincipalCollectionResource
-from twisted.web2.dav.resource import AccessDeniedError, DAVPrincipalResource, DAVPrincipalCollectionResource
+from twisted.web2.dav.resource import AccessDeniedError, DAVPrincipalCollectionResource
 from twisted.web2.dav.davxml import dav_namespace
 from twisted.web2.dav.http import ErrorResponse
 from twisted.web2.dav.resource import TwistedACLInheritable
@@ -50,7 +50,7 @@
 
 import twistedcaldav
 from twistedcaldav import caldavxml, customxml
-from twistedcaldav.extensions import DAVResource
+from twistedcaldav.extensions import DAVResource, DAVPrincipalResource
 from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource
 from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.customxml import calendarserver_namespace

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


More information about the calendarserver-changes mailing list