[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/securitypolicy/browser/granting. Changed to use modified-base64 encodings for principal ids in

Jim Fulton jim at zope.com
Tue Oct 19 15:16:02 EDT 2004


Log message for revision 28215:
  Changed to use modified-base64 encodings for principal ids in
  form-element names.
  M      src/zope/app/securitypolicy/grantinfo.py
  
  Change to return Unset when there are no grants, to be consistent with
  the interface.
  

Changed:
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py
  U   Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt

-=-
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py	2004-10-19 19:15:59 UTC (rev 28214)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.py	2004-10-19 19:16:01 UTC (rev 28215)
@@ -57,13 +57,17 @@
         principal = self.principal_widget.getInputValue()
         self.principal = principal
 
+        # Make sure we can use the principal id in a form by base64ing it
+        principal_token = unicode(principal).encode('base64').strip().replace(
+            '=', '_')
+
         roles = [role for name, role in zapi.getUtilitiesFor(IRole)]
         roles.sort(lambda x, y: cmp(x.title, y.title))
         principal_roles = IPrincipalRoleManager(self.context)
 
         self.roles = []
         for role in roles:
-            name = principal + '.role.'+role.id
+            name = principal_token + '.role.'+role.id
             field = zope.schema.Choice(__name__= name,
                                        title=role.title,
                                        vocabulary=settings_vocabulary)
@@ -79,7 +83,7 @@
         for perm in perms:
             if perm.id == 'zope.Public':
                 continue
-            name = principal + '.permission.'+perm.id
+            name = principal_token + '.permission.'+perm.id
             field = zope.schema.Choice(__name__=name,
                                        title=perm.title,
                                        vocabulary=settings_vocabulary)
@@ -92,7 +96,7 @@
             return u''
         
         for role in roles:
-            name = principal + '.role.'+role.id
+            name = principal_token + '.role.'+role.id
             role_widget = getattr(self, name+'_widget')
             if role_widget.hasInput():
                 setting = role_widget.getInputValue()
@@ -110,7 +114,7 @@
         for perm in perms:
             if perm.id == 'zope.Public':
                 continue
-            name = principal + '.permission.'+perm.id
+            name = principal_token + '.permission.'+perm.id
             perm_widget = getattr(self, name+'_widget')
             if perm_widget.hasInput():
                 setting = perm_widget.getInputValue()

Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt	2004-10-19 19:15:59 UTC (rev 28214)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt	2004-10-19 19:16:01 UTC (rev 28215)
@@ -163,19 +163,19 @@
 
   >>> from zope.app.security import settings
 
-  >>> view.request.form['field.jim.role.role1'] = 'unset'
-  >>> view.request.form['field.jim.role.role1-empty-makrer'] = 1
-  >>> view.request.form['field.jim.role.role2'] = 'allow'
-  >>> view.request.form['field.jim.role.role2-empty-makrer'] = 1
-  >>> view.request.form['field.jim.role.role3'] = 'deny'
-  >>> view.request.form['field.jim.role.role3-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.role.role1'] = 'unset'
+  >>> view.request.form['field.amlt.role.role1-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.role.role2'] = 'allow'
+  >>> view.request.form['field.amlt.role.role2-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.role.role3'] = 'deny'
+  >>> view.request.form['field.amlt.role.role3-empty-makrer'] = 1
 
-  >>> view.request.form['field.jim.permission.permission1'] = 'unset'
-  >>> view.request.form['field.jim.permission.permission1-empty-makrer'] = 1
-  >>> view.request.form['field.jim.permission.permission2'] = 'allow'
-  >>> view.request.form['field.jim.permission.permission2-empty-makrer'] = 1
-  >>> view.request.form['field.jim.permission.permission3'] = 'deny'
-  >>> view.request.form['field.jim.permission.permission3-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.permission.permission1'] = 'unset'
+  >>> view.request.form['field.amlt.permission.permission1-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.permission.permission2'] = 'allow'
+  >>> view.request.form['field.amlt.permission.permission2-empty-makrer'] = 1
+  >>> view.request.form['field.amlt.permission.permission3'] = 'deny'
+  >>> view.request.form['field.amlt.permission.permission3-empty-makrer'] = 1
 
   >>> view.request.form['GRANT_SUBMIT'] = 'Submit'
 
@@ -199,4 +199,4 @@
   >>> roles.getSetting('permission2', 'jim') is settings.Allow
   True
   >>> roles.getSetting('permission3', 'jim') is settings.Deny
-  True
\ No newline at end of file
+  True



More information about the Zope3-Checkins mailing list