[CalendarServer-changes] [3837] CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/ Twisted/twisted.web2.dav.method.report_principal_match.patch
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 12 09:29:49 PDT 2009
Revision: 3837
http://trac.macosforge.org/projects/calendarserver/changeset/3837
Author: exarkun at twistedmatrix.com
Date: 2009-03-12 09:29:49 -0700 (Thu, 12 Mar 2009)
Log Message:
-----------
Remove parts already in Twisted
Modified Paths:
--------------
CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch
Modified: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch 2009-03-12 16:11:56 UTC (rev 3836)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch 2009-03-12 16:29:49 UTC (rev 3837)
@@ -1,112 +1,47 @@
Index: twisted/web2/dav/method/report_principal_match.py
===================================================================
---- twisted/web2/dav/method/report_principal_match.py (revision 19773)
+--- twisted/web2/dav/method/report_principal_match.py (revision 26343)
+++ twisted/web2/dav/method/report_principal_match.py (working copy)
-@@ -89,40 +89,64 @@
- responses = []
- matchcount = 0
-
-- selfPrincipal = self.currentPrincipal(request).children[0]
-+ selfPrincipalURL = self.currentPrincipal(request).children[0]
-
-- # Do some optimisation of access control calculation by determining any inherited ACLs outside of
-- # the child resource loop and supply those to the checkPrivileges on each child.
-- filteredaces = waitForDeferred(self.inheritedACEsforChildren(request))
-- yield filteredaces
-- filteredaces = filteredaces.getResult()
--
-- children = []
-- d = waitForDeferred(self.findChildren("infinity", request, lambda x, y: children.append((x,y)),
-- privileges=(davxml.Read(),), inherited_aces=filteredaces))
-- yield d
-- d.getResult()
--
- if lookForPrincipals:
-
-- for child, uri in children:
-- if isPrincipalResource(child) and child.principalMatch(selfPrincipal):
-- # Check size of results is within limit
-- matchcount += 1
-- if matchcount > max_number_of_matches:
-- raise NumberOfMatchesWithinLimits
-+ # Find the set of principals that represent "self".
-+
-+ # First add "self"
-+ principal = waitForDeferred(request.locateResource(str(selfPrincipalURL)))
-+ yield principal
-+ principal = principal.getResult()
-+ selfItems = [principal,]
-+
-+ # Get group memberships for "self" and add each of those
+@@ -102,7 +102,10 @@
+ selfItems = [principal,]
+
+ # Get group memberships for "self" and add each of those
+- selfItems.extend(principal.groupMemberships())
+ d = waitForDeferred(principal.groupMemberships())
+ yield d
+ memberships = d.getResult()
+ selfItems.extend(memberships)
-+
-+ # Now add each principal found to the response provided the principal resource is a child of
-+ # the current resource.
-+ for principal in selfItems:
-+ # Get all the URIs that point to the principal resource
-+ # FIXME: making the assumption that the principalURL() is the URL of the resource we found
-+ principal_uris = [principal.principalURL()]
-+ principal_uris.extend(principal.alternateURIs())
-+
-+ # Compare each one to the request URI and return at most one that matches
-+ for uri in principal_uris:
-+ if uri.startswith(request.uri):
-+ # Check size of results is within limit
-+ matchcount += 1
-+ if matchcount > max_number_of_matches:
+
+ # Now add each principal found to the response provided the principal resource is a child of
+ # the current resource.
+@@ -118,7 +121,7 @@
+ # Check size of results is within limit
+ matchcount += 1
+ if matchcount > max_number_of_matches:
+- raise NumberOfMatchesWithinLimits
+ raise NumberOfMatchesWithinLimits(max_number_of_matches)
-+
-+ d = waitForDeferred(prop_common.responseForHref(
-+ request,
-+ responses,
-+ davxml.HRef.fromString(uri),
-+ principal,
-+ propertiesForResource,
-+ propElement
-+ ))
-+ yield d
-+ d.getResult()
-+ break
-+ else:
-+ # Do some optimisation of access control calculation by determining any inherited ACLs outside of
-+ # the child resource loop and supply those to the checkPrivileges on each child.
-+ filteredaces = waitForDeferred(self.inheritedACEsforChildren(request))
-+ yield filteredaces
-+ filteredaces = filteredaces.getResult()
-+
-+ children = []
-+ d = waitForDeferred(self.findChildren("infinity", request, lambda x, y: children.append((x,y)),
-+ privileges=(davxml.Read(),), inherited_aces=filteredaces))
-+ yield d
-+ d.getResult()
-
-- d = waitForDeferred(prop_common.responseForHref(
-- request,
-- responses,
-- davxml.HRef.fromString(uri),
-- child,
-- propertiesForResource,
-- propElement
-- ))
-- yield d
-- d.getResult()
-- else:
- for child, uri in children:
- # Try to read the requested property from this resource
- try:
-@@ -137,22 +161,26 @@
+
+ d = waitForDeferred(prop_common.responseForHref(
+ request,
+@@ -158,22 +161,26 @@
yield principal
principal = principal.getResult()
-- if principal and isPrincipalResource(principal) and principal.principalMatch(selfPrincipal):
+- if principal and isPrincipalResource(principal) and principal.principalMatch(myPrincipalURL):
- # Check size of results is within limit
- matchcount += 1
- if matchcount > max_number_of_matches:
- raise NumberOfMatchesWithinLimits
--
++ if principal and isPrincipalResource(principal):
++ d = waitForDeferred(principal.principalMatch(myPrincipalURL))
++ yield d
++ matched = d.getResult()
++ if matched:
++ # Check size of results is within limit
++ matchcount += 1
++ if matchcount > max_number_of_matches:
++ raise NumberOfMatchesWithinLimits(max_number_of_matches)
+
- d = waitForDeferred(prop_common.responseForHref(
- request,
- responses,
@@ -115,17 +50,8 @@
- propertiesForResource,
- propElement
- ))
-+ if principal and isPrincipalResource(principal):
-+ d = waitForDeferred(principal.principalMatch(selfPrincipalURL))
- yield d
+- yield d
- d.getResult()
-+ matched = d.getResult()
-+ if matched:
-+ # Check size of results is within limit
-+ matchcount += 1
-+ if matchcount > max_number_of_matches:
-+ raise NumberOfMatchesWithinLimits(max_number_of_matches)
-+
+ d = waitForDeferred(prop_common.responseForHref(
+ request,
+ responses,
@@ -139,7 +65,7 @@
except HTTPError:
# Just ignore a failure to access the property. We treat this like a property that does not exist
# or does not match the principal.
-@@ -162,7 +190,7 @@
+@@ -183,7 +190,7 @@
log.err("Too many matching components in principal-match report")
raise HTTPError(ErrorResponse(
responsecode.FORBIDDEN,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090312/313954e2/attachment-0001.html>
More information about the calendarserver-changes
mailing list