[CalendarServer-changes] [5364] CalendarServer/trunk/twext/web2/dav/resource.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 19 14:39:45 PDT 2010


Revision: 5364
          http://trac.macosforge.org/projects/calendarserver/changeset/5364
Author:   wsanchez at apple.com
Date:     2010-03-19 14:39:44 -0700 (Fri, 19 Mar 2010)
Log Message:
-----------
Unroll defGen

Modified Paths:
--------------
    CalendarServer/trunk/twext/web2/dav/resource.py

Modified: CalendarServer/trunk/twext/web2/dav/resource.py
===================================================================
--- CalendarServer/trunk/twext/web2/dav/resource.py	2010-03-19 21:29:00 UTC (rev 5363)
+++ CalendarServer/trunk/twext/web2/dav/resource.py	2010-03-19 21:39:44 UTC (rev 5364)
@@ -1352,30 +1352,29 @@
         """
         
         # Get the parent ACLs with inheritance and preserve the <inheritable> element.
-        parent_acl = waitForDeferred(self.accessControlList(request, inheritance=True, expanding=True))
-        yield parent_acl
-        parent_acl = parent_acl.getResult()
-        
-        # Check disabled
-        if parent_acl is None:
-            yield None
-            return
 
-        # Filter out those that are not inheritable (and remove the inheritable element from those that are)
-        aces = []
-        for ace in parent_acl.children:
-            if ace.inherited:
-                aces.append(ace)
-            elif TwistedACLInheritable() in ace.children:
-                # Adjust ACE for inherit on this resource
-                children = list(ace.children)
-                children.remove(TwistedACLInheritable())
-                children.append(davxml.Inherited(davxml.HRef(request.urlForResource(self))))
-                aces.append(davxml.ACE(*children))
-        yield aces
+        def gotACL(parent_acl):
+            # Check disabled
+            if parent_acl is None:
+                return None
 
-    inheritedACEsforChildren = deferredGenerator(inheritedACEsforChildren)
+            # Filter out those that are not inheritable (and remove the inheritable element from those that are)
+            aces = []
+            for ace in parent_acl.children:
+                if ace.inherited:
+                    aces.append(ace)
+                elif TwistedACLInheritable() in ace.children:
+                    # Adjust ACE for inherit on this resource
+                    children = list(ace.children)
+                    children.remove(TwistedACLInheritable())
+                    children.append(davxml.Inherited(davxml.HRef(request.urlForResource(self))))
+                    aces.append(davxml.ACE(*children))
+            return aces
 
+        d = self.accessControlList(request, inheritance=True, expanding=True)
+        d.addCallback(gotACL)
+        return d
+
     def inheritedACLSet(self):
         """
         @return: a sequence of L{davxml.HRef}s from which ACLs are inherited.
@@ -1520,8 +1519,6 @@
         d.addCallback(resolved)
         return d
 
-
-    @deferredGenerator
     def principalIsGroupMember(self, principal1, principal2, request):
         """
         Check whether one principal is a group member of another.
@@ -1531,23 +1528,25 @@
         @param request: the request being processed.
         @return: L{Deferred} with result C{True} if principal1 is a member of principal2, C{False} otherwise
         """
-        
-        d = waitForDeferred(request.locateResource(principal2))
-        yield d
-        group = d.getResult()
+        def gotGroup(group):
+            # Get principal resource for principal2
+            if group and isinstance(group, DAVPrincipalResource):
+                def gotMembers(members):
+                    for member in members:
+                        if member.principalURL() == principal1:
+                            return True
+                    return False
 
-        # Get principal resource for principal2
-        if group and isinstance(group, DAVPrincipalResource):
-            d = waitForDeferred(group.expandedGroupMembers())
-            yield d
-            members = d.getResult()
-            for member in members:
-                if member.principalURL() == principal1:
-                    yield True
-                    return
-            
-        yield False
+                d = group.expandedGroupMembers()
+                d.addCallback(gotMembers)
+                return d
+
+            return False
         
+        d = request.locateResource(principal2)
+        d.addCallback(gotGroup)
+        return d
+        
     def validPrincipal(self, ace_principal, request):
         """
         Check whether the supplied principal is valid for this resource.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100319/4737a3a1/attachment.html>


More information about the calendarserver-changes mailing list