[Checkins] SVN: z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py Fixed issue where groups were not being inspected properly, the group object was expected to be stored on the principal's group list instead of the id of the group being stored on the principal's group list.

Daniel Blackburn blackburnd at gmail.com
Wed May 28 09:19:33 EDT 2008


Log message for revision 86994:
  Fixed issue where groups were not being inspected properly, the group object was expected to be stored on the principal's group list instead of the id of the group being stored on the principal's group list.

Changed:
  U   z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py

-=-
Modified: z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py
===================================================================
--- z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py	2008-05-28 13:06:59 UTC (rev 86993)
+++ z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py	2008-05-28 13:19:32 UTC (rev 86994)
@@ -192,25 +192,22 @@
         viewPermMatrix and inspects the inherited permissions from groups
         assigned to the  principal.
         """
+        #TODO make this a breadth first search and not depth first!!
+        sysPrincipals = zapi.principals()
         matrix = self.viewMatrix
         for principal in principals:
-            subGroupLst = []
-            for group in principal.groups:
-                # We populate the subgroup list here and use it later
-                # to make this a breadth-first search instead of depth-first.
+            for group_id in principal.groups:
+                # If we have further groups... recurse
+                group = sysPrincipals.getPrincipal(group_id)
                 if group.groups:
-                    subGroupLst.extend(groups)
-                res = matrix[group.id]
-                for item in res:
-                    # We only want the setting if we do not alread have it.
-                    if item not in matrix[principal.id]:
-                        matrix[principal.id].setdefault(item,res[item])
-                            # If we have further groups... recurse
+                    mergePermissionsFromGroups(group.groups)
 
-            # Now we recurse through the child groups.
-            for group in subGroupLst:
-                mergePermissionsFromGroups(group)
-
+                if matrix.has_key(group_id):
+                    res = matrix[group_id]
+                    for item in res:
+                        # We only want the setting if we do not alread have it.
+                        if item not in matrix[principal.id]:
+                            matrix[principal.id].setdefault(item,res[item])
                 
 class MatrixDetails(object):
     """
@@ -394,8 +391,7 @@
         principal = principals.getPrincipal(principal_id)
 
         if principal.groups:
-            for group in principal.groups:
-                group_id = group.id
+            for group_id in principal.groups:
                 gMatrix = {group_id: self(group_id,view_name,skin)}
                 pMatrix['groups'].update(gMatrix)
 
@@ -481,8 +477,7 @@
         principal = principals.getPrincipal(principal_id)
 
         if principal.groups:
-            for group in principal.groups:
-                group_id = group.id
+            for group_id in principal.groups:
                 gMatrix = {group_id: self(group_id)}
                 pMatrix['groups'].update(gMatrix)
                 



More information about the Checkins mailing list