[CalendarServer-changes] [464] CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource. patch

source_changes at macosforge.org source_changes at macosforge.org
Tue Nov 14 21:03:22 PST 2006


Revision: 464
          http://trac.macosforge.org/projects/calendarserver/changeset/464
Author:   cdaboo at apple.com
Date:     2006-11-14 21:03:22 -0800 (Tue, 14 Nov 2006)

Log Message:
-----------
Fix for principal-collection-set property value.

Modified Paths:
--------------
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch	2006-11-15 04:34:46 UTC (rev 463)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.resource.patch	2006-11-15 05:03:22 UTC (rev 464)
@@ -26,7 +26,16 @@
          return succeed(qname in self.liveProperties or self.deadProperties().contains(qname))
  
      def readProperty(self, property, request):
-@@ -286,7 +296,33 @@
+@@ -253,7 +263,7 @@
+ 
+                 if name == "principal-collection-set":
+                     d = self.principalCollections(request)
+-                    d.addCallback(lambda collections: davxml.PrincipalCollectionSet(*collections))
++                    d.addCallback(lambda collections: davxml.PrincipalCollectionSet(*[davxml.HRef.fromString(uri) for uri in collections]))
+                     return d
+ 
+                 def ifAllowed(privileges, callback):
+@@ -286,6 +296,32 @@
                          d.addCallback(gotACL)
                          return d
                      return ifAllowed((davxml.ReadACL(),), callback)
@@ -43,7 +52,7 @@
 +                    d = self.quota(request)
 +                    d.addCallback(callback)
 +                    return d
- 
++
 +                if name == "quota-used-bytes":
 +                    def callback(qvalue):
 +                        if qvalue is None:
@@ -56,11 +65,10 @@
 +                    d = self.quota(request)
 +                    d.addCallback(callback)
 +                    return d
-+
+ 
              elif namespace == twisted_dav_namespace:
                  if name == "resource-class":
-                     class ResourceClass (davxml.WebDAVTextElement):
-@@ -366,12 +402,26 @@
+@@ -366,6 +402,18 @@
          # FIXME: A set would be better here, that that's a python 2.4+ feature.
          qnames = list(self.liveProperties)
  
@@ -79,15 +87,17 @@
          for qname in self.deadProperties().list():
              if (qname not in qnames) and (qname[0] != twisted_private_namespace):
                  qnames.append(qname)
+@@ -370,7 +418,9 @@
+             if (qname not in qnames) and (qname[0] != twisted_private_namespace):
+                 qnames.append(qname)
  
 -        return succeed(qnames)
 +        yield qnames
++
++    listProperties = deferredGenerator(listProperties)
  
-+    listProperties = deferredGenerator(listProperties)
-+
      def listAllprop(self, request):
          """
-         Some DAV properties should not be returned to a C{DAV:allprop} query.
 @@ -509,6 +559,9 @@
              reactor.callLater(0, getChild)
  
@@ -159,7 +169,7 @@
                      response = UnauthorizedResponse(request.credentialFactories,
                                                      request.remoteAddr)
                  else:
-@@ -600,16 +656,22 @@
+@@ -600,8 +656,13 @@
  
      def authenticate(self, request):
          def loginSuccess(result):
@@ -175,6 +185,7 @@
  
          if not (
              hasattr(request, 'portal') and 
+@@ -608,8 +669,9 @@
              hasattr(request, 'credentialFactories') and
              hasattr(request, 'loginInterfaces')
          ):
@@ -201,7 +212,7 @@
  
                  def login(pcreds):
                      d = request.portal.login(pcreds, None, *request.loginInterfaces)
-@@ -635,13 +699,14 @@
+@@ -635,7 +699,7 @@
  
                      return d
  
@@ -210,6 +221,9 @@
                  d.addCallback(gotDetails).addCallback(login)
  
                  return d
+@@ -640,8 +704,9 @@
+ 
+                 return d
          else:
 -            request.user = davxml.Principal(davxml.Unauthenticated())
 -            return request.user
@@ -233,7 +247,7 @@
          else:
              return unauthenticatedPrincipal
  
-@@ -666,32 +731,26 @@
+@@ -666,31 +731,25 @@
          present on this resource, it tries to get it from the parent, unless it
          is the root or has no parent.
          """
@@ -257,19 +271,16 @@
 -            myURL = request.urlForResource(self)
 -            if myURL != "/":
 -                parentURL = parentForURL(myURL)
+-
+-                parent = waitForDeferred(request.locateResource(parentURL))
+-                yield parent
+-                parent = parent.getResult()
 +        def gotParent(parent):
 +            if parent is None:
 +                return ()
 +            else:
 +                return parent.principalCollections(request)
  
--                parent = waitForDeferred(request.locateResource(parentURL))
--                yield parent
--                parent = parent.getResult()
-+        d = request.locateResource(parentForURL(myURL))
-+        d.addCallback(gotParent)
-+        return d
- 
 -                if parent:
 -                    principalCollections = waitForDeferred(parent.principalCollections(request))
 -                    yield principalCollections
@@ -278,11 +289,13 @@
 -        yield principalCollections
 -
 -    principalCollections = deferredGenerator(principalCollections)
--
++        d = request.locateResource(parentForURL(myURL))
++        d.addCallback(gotParent)
++        return d
+ 
      def defaultAccessControlList(self):
          """
-         @return: the L{davxml.ACL} element containing the default access control
-@@ -1146,49 +1205,95 @@
+@@ -1146,11 +1205,14 @@
  
          This implementation returns an empty set.
          """
@@ -299,6 +312,9 @@
          @param request: the L{IRequest} for the request in progress.
          @param authid: a string containing the
              authentication/authorization identifier for the principal
+@@ -1155,12 +1217,47 @@
+         @param authid: a string containing the
+             authentication/authorization identifier for the principal
              to lookup.
 -        @return: a deferred tuple of C{(principal, principalURI)}
 -            where: C{principal} is the L{Principal} that is found;
@@ -347,6 +363,7 @@
          # Try to match principals in each principal collection on the resource
          collections = waitForDeferred(self.principalCollections(request))
          yield collections
+@@ -1167,7 +1264,7 @@
          collections = collections.getResult()
  
          for collection in collections:
@@ -355,6 +372,8 @@
  
              principal = waitForDeferred(request.locateResource(principalURI))
              yield principal
+@@ -1173,22 +1270,30 @@
+             yield principal
              principal = principal.getResult()
  
 -            if isPrincipalResource(principal):
@@ -366,15 +385,15 @@
 -            principalCollections = waitForDeferred(self.principalCollections(request))
 -            yield principalCollections
 -            principalCollections = principalCollections.getResult()
-+            yield None
-+            return
- 
+-
 -            if len(principalCollections) == 0:
 -                log.msg("DAV:principal-collection-set property cannot be found on the resource being authorized: %s" % self)
 -            else:
 -                log.msg("Could not find principal matching user id: %s" % authid)
 -            raise HTTPError(responsecode.FORBIDDEN)
--
++            yield None
++            return
+ 
      findPrincipalForAuthID = deferredGenerator(findPrincipalForAuthID)
  
 +    def authorizationPrincipal(self, request, authid, authnPrincipal, authnURI):

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


More information about the calendarserver-changes mailing list