[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security/grants - configure.zcml:1.8 grant.pt:1.5 manage_access.pt:1.6 manage_permissionform.pt:1.4 manage_roleform.pt:1.4 principal_permission_edit.pt:1.5 principal_role_association.pt:1.6 principalpermissionview.py:1.7 principalroleview.py:1.8 rolepermissionview.py:1.7

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Aug 7 14:42:04 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/security/grants
In directory cvs.zope.org:/tmp/cvs-serv26029/security/grants

Modified Files:
	configure.zcml grant.pt manage_access.pt 
	manage_permissionform.pt manage_roleform.pt 
	principal_permission_edit.pt principal_role_association.pt 
	principalpermissionview.py principalroleview.py 
	rolepermissionview.py 
Log Message:
Internationalized the rest of zope/app/browser.

I also took the chance to clean up some old code and remove a lot of cruft.
(This is the reason I decided to do it instead of letting a less 
experienced developer do it.)

I now consider I18n of the Zope core done. What does this mean to you?

1. All code you check into the CVS must be internationalized. That means:

   (a) Python and PT code must be properly tagged.

   (b) zope.pot must be updated. This can be done with::

       [zope/app/translation_files]$ python extract.py

       Note: You do not need to merge the new POT file with the catalogs.

2. Any code snippet that has no I18n is considered a bug! Therefore, please
   take care and do the I18n and make code so when you see missing spots.

Finally I would like to mention that some forms might experience some 
hickups, as I changed and moved around a lot of templates and was not able
to verify them all by hand. Please let me know, if something that used to 
work is not working anymore.


=== Zope3/src/zope/app/browser/security/grants/configure.zcml 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/security/grants/configure.zcml:1.7	Sun Aug  3 13:49:24 2003
+++ Zope3/src/zope/app/browser/security/grants/configure.zcml	Thu Aug  7 13:40:56 2003
@@ -1,63 +1,35 @@
-<configure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:browser='http://namespaces.zope.org/browser'
-   i18n_domain='zope'
-   >
+<configure xmlns="http://namespaces.zope.org/browser">
 
 <!-- Role Permissions -->
 
-  <browser:pages
+  <pages
       for="zope.app.interfaces.annotation.IAnnotatable"
       permission="zope.Security"
       class=".rolepermissionview.RolePermissionView">
 
-    <browser:page name="AllRolePermissions.html"
-                  attribute="index" />
-    <browser:page name="ChangeAllRolePermissions.html"
-                  attribute="action" />
-    <browser:page name="RolePermissions.html"
-                  attribute="manage_roleForm" />
-    <browser:page name="ChangeRolePermissions.html"
-                  attribute="update_role" />
-    <browser:page name="RolesWithPermission.html"
-                  attribute="manage_permissionForm" />
-    <browser:page name="ChangeRolesWithPermission.html"
-                  attribute="update_permission" />
-  </browser:pages>
+    <page name="AllRolePermissions.html" template="manage_access.pt" />
+          <!-- menu="zmi_actions" title="Role Permissions" / -->
+    <page name="RolePermissions.html" template="manage_roleform.pt" />
+    <page name="RolesWithPermission.html" template="manage_permissionform.pt"/>
 
-  <!--browser:menuItem
-      for="zope.app.interfaces.annotation.IAnnotatable"
-      menu="zmi_actions"
-      title="Role Permissions"
-      action="@@AllRolePermissions.html"
-      /-->
+  </pages>
 
-  <browser:page
+  <page
     for="zope.app.interfaces.annotation.IAnnotatable"
     name="grant.html"
     permission="zope.Security"
     template="grant.pt" 
-    menu="zmi_actions"
-    title="Grant"
-    />
+    menu="zmi_actions" title="Grant" />
 
 <!-- Principal Roles -->
 
-  <browser:pages for="zope.app.interfaces.annotation.IAnnotatable"
-                permission="zope.Security"
-                class=".principalroleview.PrincipalRoleView">
-    <browser:page name="PrincipalRoles.html"
-                  attribute="index" />
-    <browser:page name="ChangePrincipalRoles.html"
-                  attribute="action" />
-    </browser:pages>
-
-  <!--browser:menuItem
+  <page
+      name="PrincipalRoles.html" 
       for="zope.app.interfaces.annotation.IAnnotatable"
-      menu="zmi_actions"
-      title="Principal Roles"
-      action="@@PrincipalRoles.html"
-      /-->
+      permission="zope.Security"
+      class=".principalroleview.PrincipalRoleView"
+      template="principal_role_association.pt" />
+      <!-- menu="zmi_actions" title="Principal Roles" / -->
 
 <!-- Principal Permission (not working) -->
 


=== Zope3/src/zope/app/browser/security/grants/grant.pt 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/security/grants/grant.pt:1.4	Mon Jun 30 13:10:54 2003
+++ Zope3/src/zope/app/browser/security/grants/grant.pt	Thu Aug  7 13:40:56 2003
@@ -1,11 +1,4 @@
 <html metal:use-macro="views/standard_macros/page">
-
-<head>
-
-<style metal:fill-slot="headers" type="text/css" ></style>
-
-</head>
-
 <body>
 
 <!-- XXX : This is just a temporary way of overriding the elements not needed,
@@ -13,26 +6,20 @@
                                                 - Alexander
                                                 -->
 <div metal:fill-slot="tabs" />
-
 <div metal:fill-slot="actions" />
 
 <div metal:fill-slot="body">
 
-    <p>
-
-    <a href="@@AllRolePermissions.html">Grant permissions to roles</a>
-
-    </p>
-
-    <p>
-
-    <a href="@@PrincipalRoles.html">Grant roles to principals</a>
-
-    </p>
+  <p>
+    <a href="@@AllRolePermissions.html" 
+       i18n:translate="">Grant permissions to roles</a>
+  </p>
+  <p>
+    <a href="@@PrincipalRoles.html" 
+       i18n:translate="">Grant roles to principals</a>
+  </p>
 
 </div>
-
 </body>
-
 </html>
 


=== Zope3/src/zope/app/browser/security/grants/manage_access.pt 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/security/grants/manage_access.pt:1.5	Wed Jun 25 14:43:07 2003
+++ Zope3/src/zope/app/browser/security/grants/manage_access.pt	Thu Aug  7 13:40:56 2003
@@ -1,92 +1,99 @@
 <html metal:use-macro="views/standard_macros/dialog">
 <head>
-<tal:block  
-    metal:fill-slot="headers" 
-    tal:define="global pagetip string:
-    For each permission you want to grant (or deny) to a role, 
-    set the entry for that permission and role to a '+' (or '-').
-    Permissions are shown on the left side, going down.
-    Roles are shown accross the top.
-    "
-    />
+  <tal:block  
+      metal:fill-slot="headers" 
+      tal:define="global pagetip string:
+      For each permission you want to grant (or deny) to a role, 
+      set the entry for that permission and role to a '+' (or '-').
+      Permissions are shown on the left side, going down.
+      Roles are shown accross the top.
+      "
+      />
 </head>
-<body bgcolor="#ffffff" link="#000099" alink="#000099" vlink="#000099">
-
+<body>
 <div metal:fill-slot="body">
 
-<form action="ChangeAllRolePermissions.html" method="post">
-
-<table width="100%" cellspacing="0" cellpadding="2" border="0" nowrap="nowrap">
-<tr class="list-header">
-    <td align="left" valign="top">
-      <div class="form-label">
-        <strong>Permission</strong>
-      </div>
-  </td>
-  <td align="left">
-  <div class="form-label">
-  <strong>Roles</strong>
-  </div>
-  </td>
-</tr>
-
-<tr class="row-normal">
-  <td></td>
-  <td align="center" tal:repeat="role view/roles">
-    <div class="list-item">
-      <a href="RolePermissions.html"
-        tal:attributes="
-        href string:RolePermissions.html?role_to_manage=${role/getId}" 
-        tal:content="role/getTitle">Anonymous</a>
-      <input type="hidden" name="r0" value=""
-        tal:attributes="
-        name string:r${repeat/role/index};
-        value  string:${role/getId}" />
-
-    </div>
-  </td>
-</tr>
-
-<tbody tal:repeat="perm view/permissionRoles">
-<tr class="row-normal"
-    tal:attributes="class python:path('repeat/perm/even') and 'row-normal' or 'row-hilite'"
-    >
-  <td align="left" nowrap="nowrap">
-    <div class="list-item">
-       <a href="RolesWithPermission.html"
-       tal:attributes="
-         href string:RolesWithPermission.html?permission_to_manage=${perm/getId}"
-       tal:content="perm/getTitle"
-       >Access Transient Objects</a>
-       <input type="hidden" name="r0" value=""
-         tal:attributes="
-         name string:p${repeat/perm/index};
-         value  string:${perm/getId}" />
-    </div>
-  </td>
-  <td align="center" tal:repeat="setting perm/roleSettings">
-    <select name="p0r0"
-       tal:attributes="name string:p${repeat/perm/index}r${repeat/setting/index}">
-        <option value="Unset"
-           tal:repeat="option view/availableSettings"
-           tal:attributes="value option/id;
-                           selected python:setting == option['id']"
-           tal:content="option/shorttitle">+</option>
-    </select>
-  </td>
-</tr>
-</tbody>
+   <p tal:define="status view/update"
+      tal:condition="status"
+      tal:content="status" />
+
+  <form action="AllRolePermissions.html" method="post">
+
+    <table width="100%" cellspacing="0" cellpadding="2" border="0" 
+           nowrap="nowrap">
+  
+      <tr class="list-header">
+        <td align="left" valign="top">
+          <div class="form-label">
+            <strong i18n:translate="">Permission</strong>
+          </div>
+        </td>
+        <td align="left">
+          <div class="form-label">
+            <strong i18n:translate="">Roles</strong>
+          </div>
+        </td>
+      </tr>
+  
+      <tr class="row-normal">
+        <td></td>
+        <td align="center" tal:repeat="role view/roles">
+          <div class="list-item">
+            <a href="RolePermissions.html"
+              tal:attributes="
+              href string:RolePermissions.html?role_to_manage=${role/getId}" 
+              tal:content="role/getTitle">Anonymous</a>
+            <input type="hidden" name="r0" value=""
+              tal:attributes="
+              name string:r${repeat/role/index};
+              value  string:${role/getId}" />
+  
+          </div>
+        </td>
+      </tr>
+  
+      <tbody tal:repeat="perm view/permissionRoles">
+      <tr class="row-normal"
+          tal:attributes="class 
+             python:path('repeat/perm/even') and 'row-normal' or 'row-hilite'">
+        <td align="left" nowrap="nowrap">
+          <div class="list-item">
+             <a href="RolesWithPermission.html"
+                tal:attributes="href 
+           string:RolesWithPermission.html?permission_to_manage=${perm/getId}"
+                tal:content="perm/getTitle"
+                >Access Transient Objects</a>
+             <input type="hidden" name="r0" value=""
+                 tal:attributes="
+                 name string:p${repeat/perm/index};
+                 value  string:${perm/getId}" />
+          </div>
+        </td>
+        <td align="center" tal:repeat="setting perm/roleSettings">
+          <select name="p0r0"
+              tal:attributes="name 
+                  string:p${repeat/perm/index}r${repeat/setting/index}">
+            <option value="Unset"
+                tal:repeat="option view/availableSettings"
+                tal:attributes="value option/id;
+                                selected python:setting == option['id']"
+                tal:content="option/shorttitle">+</option>
+          </select>
+        </td>
+      </tr>
+      </tbody>
+  
+      <tr>
+        <td colspan="5" align="left">
+          <div class="form-element">
+            <input class="form-element" type="submit" name="SUBMIT" 
+                   value="Save Changes" />
+          </div>
+        </td>
+      </tr>
+    </table>
+  </form>
 
-<tr>
-<td colspan="5" align="left">
-<div class="form-element">
-<input class="form-element" type="submit" name="submit" value="Save Changes" />
-<div tal:replace="options/message|nothing" />
-</div>
-</td>
-</tr>
-</table>
-</form>
 </div>
 </body>
 </html>


=== Zope3/src/zope/app/browser/security/grants/manage_permissionform.pt 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/security/grants/manage_permissionform.pt:1.3	Wed Jun 25 14:43:07 2003
+++ Zope3/src/zope/app/browser/security/grants/manage_permissionform.pt	Thu Aug  7 13:40:56 2003
@@ -1,80 +1,94 @@
 <html metal:use-macro="views/standard_macros/page">
 <head>
-<style metal:fill-slot="headers" type="text/css">
-<!--
-.row-normal {
-  background-color: #ffffff;
-  border: none;
-}
-
-.row-hilite {
-  background-color: #efefef;
-  border: none;
-}
--->
-</style>
+  <style metal:fill-slot="headers" type="text/css">
+    <!--
+    .row-normal {
+      background-color: #ffffff;
+      border: none;
+    }
+    
+    .row-hilite {
+      background-color: #efefef;
+      border: none;
+    }
+    -->
+  </style>
 </head>
-<body bgcolor="#ffffff" link="#000099" alink="#000099" vlink="#000099">
+<body>
 <div metal:fill-slot="body">
-<p class="form-help">
-Helpful message.
-</p>
-
-<div tal:define="perm python:view.permissionForID(request.get('permission_to_manage'))">
-<p class="form-text">
-Roles assigned to the permission
-<strong tal:content="perm/getTitle">Change DTML Methods</strong>
-(id: <strong tal:content="perm/getId">Zope.Some.Permission</strong>)
-</p>
-
-
-<form action="ChangeRolesWithPermission.html" method="post">
-<input type="hidden" name="permission_id" value="Permission Name"
-    tal:attributes="value perm/getId" />
-<div class="form-element">
-
-<table width="100%" cellspacing="0" cellpadding="2" border="0" nowrap="nowrap">
-<tr class="list-header">
-  <td align="left" valign="top">
-    <div class="form-label">
-      <strong>Role</strong>
-    </div>
-  </td>
-  <td align="left">
-    <div class="form-label">
-      <strong>Setting</strong>
-    </div>
-  </td>
-</tr>
-
-<tr class="row-normal"
-    tal:repeat="setting perm/roleSettings"
-    tal:attributes="class python:path('repeat/setting/even') and 'row-normal' or 'row-hilite'">
-  <td align="left" valign="top"
-      tal:define="ir repeat/setting/index"
-      tal:content="python:path('view/roles')[ir].getId()">
-    Manager
-  </td>
-  <td>
-    <select name="settings:list">
-        <option value="Unset"
-           tal:repeat="option view/availableSettings"
-           tal:attributes="value option/id;
-                           selected python:setting == option['id']"
-           tal:content="option/shorttitle">+</option>
-    </select>
-  </td>
-</tr>
-</table>
-
-</div>
-
-<div class="form-element">
-<input class="form-element" type="submit" name="submit" value="Save Changes" />
-</div>
-</form>
 
-</div>
+  <p tal:define="status view/update"
+     tal:condition="status"
+     tal:content="status" />
+
+  <p class="form-help" i18n:translate="">
+    Helpful message.
+  </p>
+
+  <div tal:define="perm 
+         python:view.permissionForID(request.get('permission_to_manage'))">
+
+    <p class="form-text" i18n:translate="">
+      Roles assigned to the permission
+      <strong tal:content="perm/getTitle" 
+          i18n:name="perm_title">Change DTML Methods</strong>
+      (id: <strong tal:content="perm/getId" 
+          i18n:name="perm_id">Zope.Some.Permission</strong>)
+    </p>
+
+    <form action="AllRolePermissions.html" method="post">
+
+      <input type="hidden" name="permission_id" value="Permission Name"
+          tal:attributes="value perm/getId" />
+
+        <div class="form-element">
+
+          <table width="100%" cellspacing="0" cellpadding="2" border="0" 
+              nowrap="nowrap">
+
+            <tr class="list-header">
+              <td align="left" valign="top">
+                <div class="form-label">
+                  <strong i18n:translate="">Role</strong>
+                </div>
+              </td>
+              <td align="left">
+                <div class="form-label">
+                  <strong i18n:translate="">Setting</strong>
+                </div>
+              </td>
+            </tr>
+
+            <tr class="row-normal"
+                tal:repeat="setting perm/roleSettings"
+                tal:attributes="class 
+          python:path('repeat/setting/even') and 'row-normal' or 'row-hilite'">
+              <td align="left" valign="top"
+                  tal:define="ir repeat/setting/index"
+                  tal:content="python:path('view/roles')[ir].getId()">
+                Manager
+              </td>
+              <td>
+                <select name="settings:list">
+                    <option value="Unset"
+                       tal:repeat="option view/availableSettings"
+                       tal:attributes="value option/id;
+                                       selected python:setting == option['id']"
+                       tal:content="option/shorttitle">+</option>
+                </select>
+              </td>
+            </tr>
+        </table>
+
+      </div>
+
+      <div class="form-element">
+        <input class="form-element" type="submit" name="SUBMIT_PERMS" 
+            value="Save Changes" i18n:attributes="value save-changes-button"/>
+      </div>
+    </form>
+
+  </div>
 </div>
 </body>
 </html>


=== Zope3/src/zope/app/browser/security/grants/manage_roleform.pt 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/security/grants/manage_roleform.pt:1.3	Wed Jun 25 14:43:07 2003
+++ Zope3/src/zope/app/browser/security/grants/manage_roleform.pt	Thu Aug  7 13:40:56 2003
@@ -1,60 +1,72 @@
 <html metal:use-macro="views/standard_macros/page">
-<head>
-<style metal:fill-slot="headers" type="text/css" ></style>
-</head>
-<body bgcolor="#ffffff" link="#000099" alink="#000099" vlink="#000099">
+<body>
 <div metal:fill-slot="body">
-<p class="form-help">
-Helpful message explaing about how to set specific roles
-</p>
-
-<div tal:define="role python:view.roleForID(request.get('role_to_manage'))" tal:omit-tag="">
-<p class="form-text">
-Permissions assigned to the role
-<strong tal:content="role/getTitle">Great Master Guru</strong>
-(id: <strong tal:content="role/getId">Zope.Some.Role</strong>)
-</p>
-
-
-<form action="ChangeRolePermissions.html" method="get">
-<input type="hidden" name="role_id" value="Role ID"
-    tal:attributes="value role/getId" />
-
-<table width="100%" cellspacing="0" cellpadding="2" border="0" nowrap="nowrap"
-       tal:define="availableSettings python:view.availableSettings(noacquire=1)">
-<tr class="list-header">
-  <td align="left" valign="top"
-      tal:repeat="setting availableSettings">
-    <div class="form-label">
-      <strong tal:content="setting/title">Allow</strong>
-    </div>
-  </td>
-</tr>
-
-<tr>
-  <td align="left" valign="top"
-      tal:repeat="settinginfo availableSettings">
-    <div class="form-element">
-      <select name="Unset:list" multiple="multiple" size="20"
-              tal:define="setting settinginfo/id"
-              tal:attributes="name string:${setting}:list">
-      <option tal:repeat="permissioninfo role/permissionsInfo"
-              tal:content="permissioninfo/title"
-              tal:attributes="selected python:path('permissioninfo/setting') == setting;
-                              value permissioninfo/id"
-              >Sample Permission</option>
-      </select>
-    </div>
-  </td>
-</tr>
-</table>
-
-<div class="form-element">
-<input class="form-element" type="submit" name="submit" value="Save Changes" />
-</div>
-</form>
 
-</div>
+  <p tal:define="status view/update"
+     tal:condition="status"
+     tal:content="status" />
+
+  <p class="form-help" i18n:translate="">
+    Helpful message explaining about how to set specific roles
+  </p>
+
+  <div tal:define="role 
+          python:view.roleForID(request.get('role_to_manage'))" tal:omit-tag="">
+
+    <p class="form-text" i18n:translate="">
+      Permissions assigned to the role
+      <strong tal:content="role/getTitle" 
+              i18n:name="role_title">Great Master Guru</strong>
+      (id: <strong tal:content="role/getId" 
+              i18n:name="role_id">Zope.Some.Role</strong>)
+    </p>
+
+
+    <form action="AllRolePermissions.html" method="get">
+      <input type="hidden" name="role_id" value="Role ID"
+             tal:attributes="value role/getId" />
+
+      <table width="100%" cellspacing="0" cellpadding="2" border="0" 
+             nowrap="nowrap"
+             tal:define="availableSettings 
+                python:view.availableSettings(noacquire=1)">
+
+        <tr class="list-header">
+          <td align="left" valign="top"
+              tal:repeat="setting availableSettings">
+            <div class="form-label">
+              <strong tal:content="setting/title">Allow</strong>
+            </div>
+          </td>
+        </tr>
+
+        <tr>
+          <td align="left" valign="top"
+              tal:repeat="settinginfo availableSettings">
+            <div class="form-element">
+              <select name="Unset:list" multiple="multiple" size="20"
+                      tal:define="setting settinginfo/id"
+                      tal:attributes="name string:${setting}:list">
+              <option tal:repeat="permissioninfo role/permissionsInfo"
+                      tal:content="permissioninfo/title"
+                      tal:attributes="selected 
+                         python:path('permissioninfo/setting') == setting;
+                                      value permissioninfo/id"
+                      >Sample Permission</option>
+              </select>
+            </div>
+          </td>
+        </tr>
+      </table>
+
+      <div class="form-element">
+        <input class="form-element" type="submit" name="SUBMIT_ROLE" 
+            value="Save Changes" i18n:attributes="value save-changes-button"/>
+      </div>
+    </form>
+
+  </div>
+
 </div>
 </body>
 </html>


=== Zope3/src/zope/app/browser/security/grants/principal_permission_edit.pt 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/security/grants/principal_permission_edit.pt:1.4	Mon Jun 30 13:10:54 2003
+++ Zope3/src/zope/app/browser/security/grants/principal_permission_edit.pt	Thu Aug  7 13:40:56 2003
@@ -1,83 +1,105 @@
 <html metal:use-macro="views/standard_macros/page">
-<div metal:fill-slot="body" tal:define="rprincipal_id python:request['principal_id']">
-<h1>Permission settings for
-  <span tal:replace="python:view.get_principal(rprincipal_id).getTitle()" />
-</h1>
-
-<form action="unsetPermissions.html" method="post">
-<h2>Permission Settings</h2>
-<table>
-  <tr>
-    <td valign="top">
-      <table border="0">
-        <tr>
-          <th colspan="2" align="center">Allowed Permissions</th>
-        </tr>
-        <tr tal:repeat="perm python:view.get_set_permissions_for_principal(rprincipal_id, 'Allow')">
-          <td><input type="checkbox" tal:attributes="name perm/getId"/></td>
-          <td tal:content="perm/getTitle">Permission1</td>
-        </tr>
-        <tr tal:replace="nothing">
-          <td><input type="checkbox" name="permission_ids" /></td><td>Permission2</td>
-        </tr>
-        <tr tal:replace="nothing">
-          <td><input type="checkbox" name="permission_ids" /></td><td>Permission3</td>
-        </tr>
-        <tr tal:replace="nothing">
-          <td><input type="checkbox" name="permission_ids" /></td><td>Permission5</td>
-        </tr>
-      </table>
-    </td>
-    <td valign="top"> 
-      <table border="0">
-        <tr >
-          <th colspan="2" align="center">Denied Permissions</th>
-        </tr>
-        <tr tal:repeat="perm python:view.get_set_permissions_for_principal(rprincipal_id, 'Deny')">
-          <td><input type="checkbox" tal:attributes="name perm/getId" /></td>
-          <td tal:content="perm/getTitle">Permission1</td>
-        </tr>
-        <tr tal:replace="nothing">
-          <td><input type="checkbox" name="permission_ids" /></td>
-          <td>Permission2</td>
-        </tr>
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td colspan="2" align="center">
-      <input type="submit" name="unset" value="Remove selected permission settings" />
-    </td>
-  </tr>
-</table>
-</form>
-<p>&nbsp;</p>
-<form action="./" method="post">
-<h2>Add permission settings</h2>
-  <table>
-    <tr>
-      <td>
-        <select name="permissions" multiple="multiple">
-          <option 
-            tal:repeat="perm python:view.get_unset_permissions_for_principal(rprincipal_id)" 
-            tal:attributes="value perm/getId"
-            tal:content="perm/getTitle">Perm1</option>
-          <option tal:replace="nothing">Perm2</option>
-          <option tal:replace="nothing">Perm3</option>
-          <option tal:replace="nothing">Perm4</option>
-          <option tal:replace="nothing">Perm5</option>
-        </select>
-      </td>        
-      <td valign="center">
-        <p>
-          <input type="submit" name="grantPermissions.html:method" value="Grant" />
+<body>
+<div metal:fill-slot="body"
+  tal:define="rprincipal_id python:request['principal_id']">
+
+  <h1 i18n:translate="">Permission settings for
+    <span tal:replace="python:view.get_principal(rprincipal_id).getTitle()" 
+          i18n:name="principal_title"/>
+  </h1>
+
+  <form action="unsetPermissions.html" method="post">
+    <h2 i18n:translate="">Permission Settings</h2>
+
+    <table>
+      <tr>
+        <td valign="top">
+          <table border="0">
+            <tr>
+              <th colspan="2" align="center" 
+                  i18n:translate="">Allowed Permissions</th>
+            </tr>
+            <tr tal:repeat="perm 
+       python:view.get_set_permissions_for_principal(rprincipal_id, 'Allow')">
+              <td><input type="checkbox" tal:attributes="name perm/getId"/></td>
+              <td tal:content="perm/getTitle">Permission1</td>
+            </tr>
+            <tr tal:replace="nothing">
+              <td><input type="checkbox" name="permission_ids" /></td>
+              <td>Permission2</td>
+            </tr>
+            <tr tal:replace="nothing">
+              <td><input type="checkbox" name="permission_ids" /></td>
+              <td>Permission3</td>
+            </tr>
+            <tr tal:replace="nothing">
+              <td><input type="checkbox" name="permission_ids" /></td>
+              <td>Permission5</td>
+            </tr>
+          </table>
+        </td>
+        <td valign="top"> 
+          <table border="0">
+            <tr >
+              <th colspan="2" align="center" 
+                  i18n:translate="">Denied Permissions</th>
+            </tr>
+            <tr tal:repeat="perm 
+       python:view.get_set_permissions_for_principal(rprincipal_id, 'Deny')">
+              <td>
+                <input type="checkbox" tal:attributes="name perm/getId" />
+              </td>
+              <td tal:content="perm/getTitle">Permission1</td>
+            </tr>
+            <tr tal:replace="nothing">
+              <td><input type="checkbox" name="permission_ids" /></td>
+              <td>Permission2</td>
+            </tr>
+          </table>
+        </td>
+      </tr>
+      <tr>
+        <td colspan="2" align="center">
+          <input type="submit" name="unset" 
+                 value="Remove selected permission settings" 
+                 i18n:attributes="value"/>
+        </td>
+      </tr>
+    </table>
+  </form>
+
+  <p>&nbsp;</p>
+
+  <form action="./" method="post">
+    <h2 i18n:translate="">Add permission settings</h2>
+
+    <table>
+      <tr>
+        <td>
+          <select name="permissions" multiple="multiple">
+            <option 
+              tal:repeat="perm 
+                python:view.get_unset_permissions_for_principal(rprincipal_id)"
+              tal:attributes="value perm/getId"
+              tal:content="perm/getTitle">Perm1</option>
+            <option tal:replace="nothing">Perm2</option>
+            <option tal:replace="nothing">Perm3</option>
+          </select>
+        </td>        
+        <td valign="center">
+          <p>
+            <input type="submit" name="grantPermissions.html:method" 
+                   value="Grant" i18n:attributes="value grant-button"/>
           </p>
-        <p>
-          <input type="submit" name="denyPermissions.html:method" value="Deny" />
+          <p>
+            <input type="submit" name="denyPermissions.html:method"
+                   value="Deny" i18n:attributes="value grant-button"/>
           </p>
-      </td>
-    </tr>
-  </table>
-</form>
+        </td>
+      </tr>
+    </table>
+  </form>
+
 </div>
+</body>
 </html>


=== Zope3/src/zope/app/browser/security/grants/principal_role_association.pt 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/security/grants/principal_role_association.pt:1.5	Wed Jun 25 18:14:25 2003
+++ Zope3/src/zope/app/browser/security/grants/principal_role_association.pt	Thu Aug  7 13:40:56 2003
@@ -1,98 +1,100 @@
 <html metal:use-macro="views/standard_macros/dialog">
-  <head>
-    <style metal:fill-slot="headers" type="text/css"> </style>
-  </head>
-  <body metal:fill-slot="body"
-        tal:define="hasFilter python:request.get('Filter', None)">
-
-      <div tal:replace="options/message|nothing" />
-
-      <div tal:condition="not: hasFilter">
-        <span class="message"> Apply filter </span>
-        <form method="POST" action="@@PrincipalRoles.html">
-           Principal(s):
-            <select name="principals:list" multiple="multiple">
-             <option tal:repeat="principal view/getAllPrincipals"
-                     tal:attributes="value principal/getId"
-                     tal:content="principal/getTitle">my title</option>
-            </select>
-
-           Role(s):
-            <select name="roles:list" multiple="multiple">
-             <option tal:repeat="role view/getAllRoles"
-                     tal:attributes="value role/getId"
-                     tal:content="role/getTitle">my title</option>
-            </select>
-
-           <input type="submit" name="Filter" value="Filter" />
-        </form>
-
-      </div>
-
-      <!-- WARNING!! SELF POSTING FORM!! -->
-
-      <div tal:condition="hasFilter">
-        <div class="principalRolesGrid"
-             tal:define="principalRoleGrid view/createGrid">
-
-          <span tal:define="
-              global listPrincipals principalRoleGrid/principals;
-              global listRoles principalRoleGrid/roles;
-              global listValues principalRoleGrid/listAvailableValues" />
-
-          <form method="POST" action="ChangePrincipalRoles.html">
-          <table>
-            <tr class="roleHeading">
-              <td class="principal">
-                &nbsp;
-              </td>
-              <td class="role" tal:repeat="role listRoles" 
-                               tal:content="role/getTitle">
-                Role Id
-              </td>
-            </tr>
-
-            <tr class="principalRoleRow" tal:repeat="principal listPrincipals">
-              <td class="principalLabel" tal:content="principal/getTitle">
-                Principal Id
-              </td>
-
-              <td class="principalRole" tal:repeat="role listRoles">
-                <select name="grid.role.principal:records"
-                        tal:attributes="
-                         name string:grid.${role/getId}.${principal/getId}"
-                        tal:define="selectedValue 
-                                    python:principalRoleGrid.getValue(
-                                               principal.getId(), 
-                                               role.getId()
-                                               )" >
-                  <option value="" tal:repeat="defaultValue listValues"
-                   tal:attributes="
-                       selected python:defaultValue==selectedValue;
-                       value defaultValue;
-                       debugsel selectedValue;
-                       "
-                   tal:content="defaultValue">
-                  &nbsp;
-                  </option>
-                </select>
-              </td>
-            </tr>
-
-          </table>
-          <input type="hidden" name="principals:list"
-            tal:repeat="principal listPrincipals"
-            tal:attributes="value principal/getId" />
-          <input type="hidden" name="roles:list"
-            tal:repeat="role listRoles"
-            tal:attributes="value role/getId" />
+<body>
+<div metal:fill-slot="body"
+   tal:define="hasFilter python:request.get('Filter', None)">
+
+   <p tal:define="status view/update"
+      tal:condition="status"
+      tal:content="status" />
+
+   <div tal:condition="not: hasFilter">
+     <span class="message" i18n:translate="">Apply filter</span>
+     <form action="@@PrincipalRoles.html" method="POST">
+       <span i18n:translate="">Principal(s):</span>
+       <select name="principals:list" multiple="multiple">
+         <option tal:repeat="principal view/getAllPrincipals"
+                 tal:attributes="value principal/getId"
+                 tal:content="principal/getTitle">my title</option>
+       </select>
+   
+       <span i18n:translate="">Role(s):</span>
+       <select name="roles:list" multiple="multiple">
+         <option tal:repeat="role view/getAllRoles"
+                 tal:attributes="value role/getId"
+                 tal:content="role/getTitle">my title</option>
+       </select>
+   
+       <input type="submit" name="Filter" value="Filter" 
+              i18n:attributes="value filter-button"/>
+     </form>
+   
+   </div>
+
+   <div tal:condition="hasFilter">
+     <div class="principalRolesGrid"
+          tal:define="principalRoleGrid view/createGrid">
+   
+       <span tal:define="
+           global listPrincipals principalRoleGrid/principals;
+           global listRoles principalRoleGrid/roles;
+           global listValues principalRoleGrid/listAvailableValues" />
+   
+       <form action="@@PrincipalRoles.html" method="POST">
+         <table>
+           <tr class="roleHeading">
+             <td class="principal">
+               &nbsp;
+             </td>
+             <td class="role" tal:repeat="role listRoles" 
+                              tal:content="role/getTitle">
+               Role Id
+             </td>
+           </tr>
+   
+           <tr class="principalRoleRow" tal:repeat="principal listPrincipals">
+             <td class="principalLabel" tal:content="principal/getTitle">
+               Principal Id
+             </td>
+   
+             <td class="principalRole" tal:repeat="role listRoles">
+               <select name="grid.role.principal:records"
+                       tal:attributes="
+                           name string:grid.${role/getId}.${principal/getId}"
+                       tal:define="selectedValue 
+                                   python:principalRoleGrid.getValue(
+                                              principal.getId(), 
+                                              role.getId()
+                                              )" >
+                 <option value="" tal:repeat="defaultValue listValues"
+                         tal:attributes="
+                             selected python:defaultValue==selectedValue;
+                             value defaultValue;
+                             debugsel selectedValue"
+                        tal:content="defaultValue">
+                   &nbsp;
+                 </option>
+               </select>
+             </td>
+           </tr>
+   
+         </table>
+
+         <input type="hidden" name="principals:list"
+                tal:repeat="principal listPrincipals"
+                tal:attributes="value principal/getId" />
+
+         <input type="hidden" name="roles:list"
+                tal:repeat="role listRoles"
+                tal:attributes="value role/getId" />
+   
+         <input type="submit" name="APPLY" value="Apply" 
+                i18n:attributes="value apply-button"/>
+   
+       </form>
+   
+     </div>
+   </div>
 
-          <input type="submit" name="apply" value="apply" />
-
-          </form>
-
-        </div>
-      </div>
-
-  </body>
+</div>
+</body>
 </html>


=== Zope3/src/zope/app/browser/security/grants/principalpermissionview.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/security/grants/principalpermissionview.py:1.6	Fri May  2 14:24:59 2003
+++ Zope3/src/zope/app/browser/security/grants/principalpermissionview.py	Thu Aug  7 13:40:56 2003
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Principal Permission View Classes
 
 $Id$
 """


=== Zope3/src/zope/app/browser/security/grants/principalroleview.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/security/grants/principalroleview.py:1.7	Thu May  1 15:35:03 2003
+++ Zope3/src/zope/app/browser/security/grants/principalroleview.py	Thu Aug  7 13:40:56 2003
@@ -11,25 +11,22 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-""" Management view component for principal-role management (Zope2's
-    "local roles").
+"""Management view component for principal-role management (Zope2's
+"local roles").
 
 $Id$
 """
-import time
+from datetime import datetime
 
+from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.interfaces.security import IPrincipalRoleManager
 from zope.app.interfaces.security import IPrincipalRoleMap
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.security.settings import Unset, Deny, Allow
-from zope.component import getService, getAdapter
 from zope.app.services.servicenames import Authentication, Roles
-from zope.publisher.browser import BrowserView
-
+from zope.component import getService, getAdapter
 
-class PrincipalRoleView(BrowserView):
 
-    index = ViewPageTemplateFile('principal_role_association.pt')
+class PrincipalRoleView:
 
     def getAllPrincipals(self):
         principals = getattr(self, '_principals', None)
@@ -70,25 +67,31 @@
 
         return PrincipalRoleGrid(principals, roles, self.context)
 
-    def action(self, principals, roles, testing=None):
-        prm = getAdapter(self.context, IPrincipalRoleManager)
-        for role in roles:
-            for principal in principals:
-                name = 'grid.%s.%s' % (role, principal)
-                setting = self.request.get(name, 'Unset')
-                if setting == 'Unset':
-                    prm.unsetRoleForPrincipal(role, principal)
-                elif setting == 'Allow':
-                    prm.assignRoleToPrincipal(role, principal)
-                elif setting == 'Deny':
-                    prm.removeRoleFromPrincipal(role, principal)
-                else:
-                    raise ValueError("Incorrect setting %s" % setting)
-
-        if not testing:
-            return self.index(
-                message="Settings changed at %s" % time.ctime(time.time())
-                )
+    def update(self, testing=None):
+        status = ''
+
+        if 'APPLY' in self.request:
+            principals = self.request.get('principals')
+            roles = self.request.get('roles')
+            prm = getAdapter(self.context, IPrincipalRoleManager)
+            for role in roles:
+                for principal in principals:
+                    name = 'grid.%s.%s' % (role, principal)
+                    setting = self.request.get(name, 'Unset')
+                    if setting == 'Unset':
+                        prm.unsetRoleForPrincipal(role, principal)
+                    elif setting == 'Allow':
+                        prm.assignRoleToPrincipal(role, principal)
+                    elif setting == 'Deny':
+                        prm.removeRoleFromPrincipal(role, principal)
+                    else:
+                        raise ValueError("Incorrect setting %s" % setting)
+
+            formatter = self.request.locale.getDateTimeFormatter('medium')
+            status = _("Settings changed at ${date_time}")
+            status.mapping = {'date_time': formatter.format(datetime.utcnow())}
+
+        return status
 
 
 class PrincipalRoleGrid:


=== Zope3/src/zope/app/browser/security/grants/rolepermissionview.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/security/grants/rolepermissionview.py:1.6	Tue Feb 11 21:17:09 2003
+++ Zope3/src/zope/app/browser/security/grants/rolepermissionview.py	Thu Aug  7 13:40:56 2003
@@ -11,27 +11,21 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Role Permission View Classes
 
 $Id$
 """
-import time
+from datetime import datetime
 
+from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.interfaces.security import IRolePermissionManager
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.security.grants.permissionroles import PermissionRoles
 from zope.app.security.grants.rolepermission import RolePermissions
 from zope.app.security.settings import Unset, Allow, Deny
-from zope.component import getService, getAdapter
 from zope.app.services.servicenames import Roles, Permissions
-from zope.publisher.browser import BrowserView
-
-
-class RolePermissionView(BrowserView):
+from zope.component import getService, getAdapter
 
-    index = ViewPageTemplateFile('manage_access.pt')
-    manage_permissionForm = ViewPageTemplateFile('manage_permissionform.pt')
-    manage_roleForm = ViewPageTemplateFile('manage_roleform.pt')
+class RolePermissionView:
 
     def roles(self):
         roles = getattr(self, '_roles', None)
@@ -50,9 +44,9 @@
         return permissions
 
     def availableSettings(self, noacquire=0):
-        aq = {'id': Unset.getName(), 'shorttitle': ' ', 'title': 'Acquire'}
-        rest = [{'id': Allow.getName(), 'shorttitle': '+', 'title': 'Allow'},
-                {'id': Deny.getName(), 'shorttitle': '-', 'title': 'Deny'},
+        aq = {'id': Unset.getName(), 'shorttitle': ' ', 'title': _('Acquire')}
+        rest = [{'id': Allow.getName(), 'shorttitle': '+', 'title': _('Allow')},
+                {'id': Deny.getName(), 'shorttitle': '-', 'title': _('Deny')},
                 ]
         if noacquire:
             return rest
@@ -79,72 +73,72 @@
                           ).getRole(rid)
         return RolePermissions(role, context, permissions)
 
-    def action(self, testing=None):
-        request = self.request
-        roles       = [r.getId() for r in self.roles()]
-        permissions = [p.getId() for p in self.permissions()]
-        prm         = getAdapter(self.context, IRolePermissionManager)
-        for ip in range(len(permissions)):
-            rperm = request.get("p%s" % ip)
-            if rperm not in permissions: continue
+
+    def update(self, testing=None):
+        status = ''
+        changed = False
+
+        if 'SUBMIT' in self.request:
+            roles       = [r.getId() for r in self.roles()]
+            permissions = [p.getId() for p in self.permissions()]
+            prm         = getAdapter(self.context, IRolePermissionManager)
+            for ip in range(len(permissions)):
+                rperm = self.request.get("p%s" % ip)
+                if rperm not in permissions: continue
+                for ir in range(len(roles)):
+                    rrole = self.request.get("r%s" % ir)
+                    if rrole not in roles: continue
+                    setting = self.request.get("p%sr%s" % (ip, ir), None)
+                    if setting is not None:
+                        if setting == Unset.getName():
+                            prm.unsetPermissionFromRole(rperm, rrole)
+                        elif setting == Allow.getName():
+                            prm.grantPermissionToRole(rperm, rrole)
+                        elif setting == Deny.getName():
+                            prm.denyPermissionToRole(rperm, rrole)
+                        else:
+                            raise ValueError("Incorrect setting: %s" % setting)
+            changed = True
+
+        if 'SUBMIT_PERMS' in self.request:
+            prm = getAdapter(self.context, IRolePermissionManager)
+            roles = self.roles()
+            rperm = self.request.get('permission_id')
+            settings = self.request.get('settings', ())
             for ir in range(len(roles)):
-                rrole = request.get("r%s" % ir)
-                if rrole not in roles: continue
-                setting = request.get("p%sr%s" % (ip, ir), None)
-                if setting is not None:
-                    if setting == Unset.getName():
-                        prm.unsetPermissionFromRole(rperm, rrole)
-                    elif setting == Allow.getName():
-                        prm.grantPermissionToRole(rperm, rrole)
-                    elif setting == Deny.getName():
-                        prm.denyPermissionToRole(rperm, rrole)
-                    else:
-                        raise ValueError("Incorrect setting: %s" % setting)
-
-        if not testing:
-            return self.index(
-                message="Settings changed at %s" % time.ctime(time.time())
-                )
-
-    def update_permission(self, permission_id,
-                          settings=(), testing=None):
-        prm = getAdapter(self.context, IRolePermissionManager)
-        roles = self.roles()
-        rperm = permission_id
-        for ir in range(len(roles)):
-            rrole = roles[ir].getId()
-            setting = settings[ir]
-            if setting == Unset.getName():
-                prm.unsetPermissionFromRole(rperm, rrole)
-            elif setting == Allow.getName():
-                prm.grantPermissionToRole(rperm, rrole)
-            elif setting == Deny.getName():
-                prm.denyPermissionToRole(rperm, rrole)
-            else:
-                raise ValueError("Incorrect setting: %s" % setting)
-
-        if not testing:
-            return self.index(message="Settings changed at %s"
-                              % time.ctime(time.time())
-                              )
-
-    def update_role(self, role_id, testing=None):
-        request = self.request
-        prm = getAdapter(self.context, IRolePermissionManager)
-        allowed = request.get(Allow.getName(), ())
-        denied = request.get(Deny.getName(), ())
-        for permission in self.permissions():
-            rperm = permission.getId()
-            if rperm in allowed and rperm in denied:
-                raise ValueError("Incorrect setting for %s" % rperm)
-            if rperm in allowed:
-                prm.grantPermissionToRole(rperm, role_id)
-            elif rperm in denied:
-                prm.denyPermissionToRole(rperm, role_id)
-            else:
-                prm.unsetPermissionFromRole(rperm, role_id)
-
-        if not testing:
-            return self.index(message="Settings changed at %s"
-                              % time.ctime(time.time())
-                              )
+                rrole = roles[ir].getId()
+                setting = settings[ir]
+                if setting == Unset.getName():
+                    prm.unsetPermissionFromRole(rperm, rrole)
+                elif setting == Allow.getName():
+                    prm.grantPermissionToRole(rperm, rrole)
+                elif setting == Deny.getName():
+                    prm.denyPermissionToRole(rperm, rrole)
+                else:
+                    raise ValueError("Incorrect setting: %s" % setting)
+            changed = True
+
+        if 'SUBMIT_ROLE' in self.request:
+            role_id = self.request.get('role_id')
+            prm = getAdapter(self.context, IRolePermissionManager)
+            allowed = self.request.get(Allow.getName(), ())
+            denied = self.request.get(Deny.getName(), ())
+            for permission in self.permissions():
+                rperm = permission.getId()
+                if rperm in allowed and rperm in denied:
+                    raise ValueError("Incorrect setting for %s" % rperm)
+                if rperm in allowed:
+                    prm.grantPermissionToRole(rperm, role_id)
+                elif rperm in denied:
+                    prm.denyPermissionToRole(rperm, role_id)
+                else:
+                    prm.unsetPermissionFromRole(rperm, role_id)
+            changed = True
+
+        if changed:
+            formatter = self.request.locale.getDateTimeFormatter('medium')
+            status = _("Settings changed at ${date_time}")
+            status.mapping = {'date_time': formatter.format(datetime.utcnow())}
+
+        return status
+




More information about the Zope3-Checkins mailing list