[Checkins]
SVN: z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py
- Misc bug fixes where groups were not displaying properly
Daniel Blackburn
blackburnd at gmail.com
Tue Feb 26 19:27:25 EST 2008
Log message for revision 84290:
- Misc bug fixes where groups were not displaying properly
- Refactored some of the superclass MatrixDetails to assume more
responsibility
- Cleanup of some unused code
- Added some more comments
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-02-27 00:25:00 UTC (rev 84289)
+++ z3c.securitytool/trunk/src/z3c/securitytool/securitytool.py 2008-02-27 00:27:25 UTC (rev 84290)
@@ -116,7 +116,6 @@
[self.name][role['role']]
except KeyError:
pass
- continue
else:
permSetting = principalRoleProvidesPermission(
@@ -171,27 +170,46 @@
#If the permisison does not exist for the prin add it
continue
- matrix[principal].update({self.name: setting})
-
-
class MatrixDetails(object):
"""
This class creates the complex permissionDetails object
"""
def __init__(self,context):
+ """
+ init method for the super class
+ """
self.context = context
+ def updatePrincipalMatrix(self, pMatrix, principal_id, settings):
+ """ this method recursively populates the principal permissions
+ dict (MatrixDetails)
+ """
+ principals = zapi.principals()
+ principal = principals.getPrincipal(principal_id)
+
+ for setting in settings:
+ for name, item in setting.items():
+ self.updateMatrixRoles(pMatrix, principal_id, name,item)
+ self.updateMatrixPermissions(pMatrix, principal_id, item)
+
def updateMatrixPermissions(self, pMatrix, principal_id, item):
""" Here we get all the permissions for the given principal
on the item passed.
"""
-
+
for prinPerms in item.get('principalPermissions', ()):
if principal_id != prinPerms['principal']:
continue
+ # If this method is being used by permissionDetails then
+ # we will have a read_perm in the self namespace. If it is
+ # the same as curPerm we can continue
+ curPerm = prinPerms['permission']
+ if getattr(self,'read_perm',curPerm) != curPerm:
+ continue
+
if item.get('parentList',None):
self.updatePermissionTree(pMatrix, item,prinPerms)
@@ -298,7 +316,6 @@
self.view_name = view_name
self.skin = skin
-
request = TestRequest()
applySkin(request, skin)
pMatrix = {'permissions': [],
@@ -309,14 +326,11 @@
ifaces = tuple(providedBy(self.context))
- ifaces = tuple(providedBy(self.context))
for iface in ifaces:
for view_reg in getViews(iface, skin):
if view_reg.name == view_name:
view = getView(self.context, view_reg, skin)
- if not view:
- continue
all_settings = [{name:val} for name,val in
settingsForObject(view) ]
@@ -340,7 +354,7 @@
if principal.groups:
for group in principal.groups:
group_id = group.id
- gMatrix = {group_id: self(group_id,view_name)}
+ gMatrix = {group_id: self(group_id,view_name,skin)}
pMatrix['groups'].update(gMatrix)
@@ -354,7 +368,6 @@
role = curRole['role']
- #import pdb;pdb.set_trace()
perm = roleProvidesPermission(self.rolePermMap,
role,
self.read_perm )
@@ -376,22 +389,9 @@
except:
#Cannot delete something that is not there
pass
- continue
else:
self.updateRoles(pMatrix, item,role,curRole)
- def updatePrincipalMatrix(self, pMatrix, principal_id, settings):
- """ this method recursively populates the principal permissions
- dict and is only used by principalPermissions """
-
- principals = zapi.principals()
- principal = principals.getPrincipal(principal_id)
-
- for setting in settings:
- for name, item in setting.items():
- self.updateMatrixRoles(pMatrix, principal.id, name,item)
- self.updateMatrixPermissions(pMatrix, principal_id, item)
-
class PrincipalDetails(MatrixDetails):
implements(interfaces.IPrincipalDetails)
adapts(Interface)
@@ -457,23 +457,9 @@
except:
#Cannot delete something that is not there
pass
- continue
else:
self.updateRoles(pMatrix,item,role,curRole)
- def updatePrincipalMatrix(self, pMatrix, principal_id, settings):
- """ this method recursively populates the principal permissions
- dict and is only used by principalPermissions """
-
- principals = zapi.principals()
- principal = principals.getPrincipal(principal_id)
-
- for setting in settings:
- for name, item in setting.items():
- self.updateMatrixRoles(pMatrix, principal_id, name,item)
- self.updateMatrixPermissions(pMatrix, principal_id, item)
-
-
def getViews(iface, reqType=IRequest):
"""Get all view registrations for a particular interface."""
gsm = getGlobalSiteManager()
@@ -593,7 +579,6 @@
parent = getattr(parent, '__parent__', None)
-
result.append((getattr(ob, '__name__', '(no name)'), data))
ob = getattr(ob, '__parent__', None)
# This is just to create an internal unique name for the object
@@ -605,8 +590,8 @@
# Here we need to add the parentlist and uid to display it properly
# in the roleTree and in the permissionTree
result[-1][1]['parentList'] = ['Root Folder']
- result[-1][1]['uid'] = 'Root Folder'
- result[-1][1]['name'] = 'Root Folder'
+ result[-1][1]['uid'] = 'Root Folder'
+ result[-1][1]['name'] = 'Root Folder'
data = {}
result.append(('global settings', data))
@@ -630,7 +615,6 @@
data['parentList'] = ['global settings']
data['uid'] = 'global settings'
-
return result
def getSettingsForMatrix(viewInstance):
More information about the Checkins
mailing list