[Checkins] SVN: z3c.securitytool/trunk/src/z3c/securitytool/ -
Renamed sortedViews to sortedPerms ( makes more sense )
Daniel Blackburn
blackburnd at gmail.com
Thu Jun 12 21:31:39 EDT 2008
Log message for revision 87356:
- Renamed sortedViews to sortedPerms ( makes more sense )
- Fixed issue where viewPrincipalMatrix was not inheriting groups
- and permissions properly, I realized this after some heavy testing
Changed:
U z3c.securitytool/trunk/src/z3c/securitytool/browser/views.py
U z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py
-=-
Modified: z3c.securitytool/trunk/src/z3c/securitytool/browser/views.py
===================================================================
--- z3c.securitytool/trunk/src/z3c/securitytool/browser/views.py 2008-06-12 23:31:32 UTC (rev 87355)
+++ z3c.securitytool/trunk/src/z3c/securitytool/browser/views.py 2008-06-13 01:31:36 UTC (rev 87356)
@@ -110,11 +110,9 @@
rather than view
"""
self.viewList = {}
+ sortedPerms = sorted([(v,k) for k,v in self.views.items()])
-
- sortedViews = sorted([(v,k) for k,v in self.views.items()])
-
- for item in sortedViews:
+ for item in sortedPerms:
if self.viewList.has_key(item[0]):
self.viewList[item[0]].append(item[1])
else:
Modified: z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py
===================================================================
--- z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py 2008-06-12 23:31:32 UTC (rev 87355)
+++ z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py 2008-06-13 01:31:36 UTC (rev 87356)
@@ -11,6 +11,9 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+from copy import deepcopy
+from pprint import pprint
+
from zope.app import zapi
from zope.app.apidoc.presentation import getViewInfoDictionary
from zope.i18nmessageid import ZopeMessageFactory as _
@@ -68,7 +71,7 @@
permissions and role-permissions permissions will always win.
"""
- # Populate the viewMatrix with the permissions gained from the
+ # Populate the viewMatrix with the permissions gained only from the
# assigned roles
for item in self.viewRoleMatrix:
@@ -80,7 +83,8 @@
self.viewMatrix[item].update({viewSetting:val})
- # Populate the viewMatrix with the permissions directly assinged.
+ # Populate the viewMatrix with the permissions which are
+ # only directly assigned.
for item in self.viewPermMatrix:
if not self.viewMatrix.has_key(item):
self.viewMatrix[item] = {}
@@ -90,12 +94,31 @@
# Now we will inherit the permissions from groups assigned to each
- # principal and digest them accordingly
+ # principal and digest them accordingly, This section populates the
+ # groupPermMatrix. The groupPermMatrix is a collection the permissinos
+ # inherited only from groups.
principals = zapi.principals()
getPrin = principals.getPrincipal
viewPrins = [getPrin(prin) for prin in self.viewMatrix]
- mergePermissionsFromGroups(viewPrins,self.viewMatrix)
+ # TODO update to a better method
+ # Here we will just populate the temp matrix with the
+ # with a copy of the contents of the viewMatrix. There
+ # is probably a better way to do this but for now ;)
+ tmpMatrix = deepcopy(self.viewMatrix)
+ mergePermissionsFromGroups(viewPrins,tmpMatrix)
+
+ # Now we merge our last set of permissions into the main viewMatrix
+ # for our display.
+ for prinItem in tmpMatrix:
+ for item in tmpMatrix[prinItem]:
+ if not self.viewMatrix[prinItem].has_key(item):
+ # We only want to add the permission if it does not exist
+ # we do not want to overwrite the permission.
+ self.viewMatrix[prinItem][item] = tmpMatrix[prinItem][item]
+
+
+
def getReadPerm(self,view_reg):
""" Helper method which returns read_perm and view name"""
info = getViewInfoDictionary(view_reg)
More information about the Checkins
mailing list