[CalendarServer-changes] [1346]
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.
report_principal_match.patch
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 8 08:55:14 PST 2007
Revision: 1346
http://trac.macosforge.org/projects/calendarserver/changeset/1346
Author: cdaboo at apple.com
Date: 2007-03-08 08:55:14 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
principal-match report speed up when doing a match for DAV:self. Got a 100x speed up when targetting a directory with
~9500 users in it!
Added Paths:
-----------
CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch
Added: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch (rev 0)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.method.report_principal_match.patch 2007-03-08 16:55:14 UTC (rev 1346)
@@ -0,0 +1,85 @@
+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 (working copy)
+@@ -89,40 +89,53 @@
+ 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):
++ # 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
++ selfItems.extend(principal.groupMemberships())
++
++ # Now add each principal found to the response provided the principal resource is a child of
++ # the current resource.
++ for principal in selfItems:
++ if principal.principalURL().startswith(request.uri):
+ # Check size of results is within limit
+ matchcount += 1
+ if matchcount > max_number_of_matches:
+ raise NumberOfMatchesWithinLimits
+-
++
+ d = waitForDeferred(prop_common.responseForHref(
+ request,
+ responses,
+- davxml.HRef.fromString(uri),
+- child,
++ davxml.HRef.fromString(principal.principalURL()),
++ principal,
+ propertiesForResource,
+ propElement
+ ))
+ yield d
+ d.getResult()
+ 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()
++
+ for child, uri in children:
+ # Try to read the requested property from this resource
+ try:
+@@ -137,7 +150,7 @@
+ yield principal
+ principal = principal.getResult()
+
+- if principal and isPrincipalResource(principal) and principal.principalMatch(selfPrincipal):
++ if principal and isPrincipalResource(principal) and principal.principalMatch(selfPrincipalURL):
+ # Check size of results is within limit
+ matchcount += 1
+ if matchcount > max_number_of_matches:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070308/29237b18/attachment.html
More information about the calendarserver-changes
mailing list