[Checkins] SVN:
z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py
Changed the group inheritance of permissions to be a breadth-first
search intead of the depth-first... oops
Jacob Holm
jh at improva.dk
Tue May 27 10:53:06 EDT 2008
Hi Daniel
This change (or possibly the checkin message) looks wrong to me. You
have not actually changed it to use breadth-first. Instead you have
changed it to do the computation in preorder (treat a principal before
its groups) instead of postorder (treat the principals groups before the
principal).
I believe that depth-first-postorder is the right way to do it.
Actually it looks like neither version will work in the presence of
groups since mergePermissionsFromGroups is a method on self and not a
global function, but that is a different matter.
Disclaimer: I have never actually used the package and I may have
misunderstood the intent of the code, I just do a random sample of the
checkin list once in a while to get a feel for what is happening in the
repository.
Hope this helps.
- Jacob
Daniel Blackburn wrote:
> Log message for revision 86978:
> Changed the group inheritance of permissions to be a breadth-first search intead of the depth-first... oops
>
> 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-27 13:05:32 UTC (rev 86977)
> +++ z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py 2008-05-27 13:30:17 UTC (rev 86978)
> @@ -188,23 +188,29 @@
>
> def mergePermissionsFromGroups(self,principals):
> """
> - This method looks through all the principals in the viewPermMatrix
> - and inspects the inherited permissions from groups assigned to the
> - principal.
> + This method recursively looks through all the principals in the
> + viewPermMatrix and inspects the inherited permissions from groups
> + assigned to the principal.
> """
> - #TODO make this a breadth first search and not depth first!!
> matrix = self.viewMatrix
> for principal in principals:
> + subGroupLst = []
> for group in principal.groups:
> - # If we have further groups... recurse
> + # We populate the subgroup list here and use it later
> + # to make this a breadth-first search instead of depth-first.
> if group.groups:
> - mergePermissionsFromGroups(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
> +
> + # Now we recurse through the child groups.
> + for group in subGroupLst:
> + mergePermissionsFromGroups(group)
> +
>
> class MatrixDetails(object):
> """
>
> _______________________________________________
> Checkins mailing list
> Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/checkins
>
More information about the Checkins
mailing list