[Zope-Checkins] CVS: Zope2 - Role.py:1.49
evan@serenade.digicool.com
evan@serenade.digicool.com
Wed, 23 May 2001 15:12:39 -0400
Update of /cvs-repository/Zope2/lib/python/AccessControl
In directory serenade:/home/evan/Zope/trunk/lib/python/AccessControl
Modified Files:
Role.py
Log Message:
Allow setting of individual permissions to fail, and note that failure in the message screen. Otherwise, faulty __ac_permission__ information can prevent changes to security.
--- Updated File Role.py in package Zope2 --
--- Role.py 2001/05/21 17:57:25 1.48
+++ Role.py 2001/05/23 19:12:38 1.49
@@ -263,15 +263,24 @@
indexes=range(len(valid_roles))
have=REQUEST.has_key
permissions=self.ac_inherited_permissions(1)
+ fails = []
for ip in range(len(permissions)):
roles=[]
for ir in indexes:
if have("p%dr%d" % (ip,ir)): roles.append(valid_roles[ir])
name, value = permissions[ip][:2]
- p=Permission(name,value,self)
- if not have('a%d' % ip): roles=tuple(roles)
- p.setRoles(roles)
+ try:
+ p=Permission(name,value,self)
+ if not have('a%d' % ip): roles=tuple(roles)
+ p.setRoles(roles)
+ except:
+ fails.append(name)
+ if fails:
+ return MessageDialog(title="Warning!",
+ message="Some permissions had errors: "
+ + join(fails, ', '),
+ action='manage_access')
return MessageDialog(
title ='Success!',
message='Your changes have been saved',