[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security/grants/tests - test_principalroleview.py:1.10 test_rolepermissionview.py:1.6

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/tests
In directory cvs.zope.org:/tmp/cvs-serv26029/security/grants/tests

Modified Files:
	test_principalroleview.py test_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/tests/test_principalroleview.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/security/grants/tests/test_principalroleview.py:1.9	Fri Jun  6 16:44:27 2003
+++ Zope3/src/zope/app/browser/security/grants/tests/test_principalroleview.py	Thu Aug  7 13:41:00 2003
@@ -18,18 +18,19 @@
 
 import unittest
 
-from zope.app.services.tests.placefulsetup\
-           import PlacefulSetup
-from zope.component import getServiceManager
-from zope.app.services.servicenames import Roles, Authentication
-
-from zope.app.interfaces.security import IRoleService
 from zope.app.interfaces.security import IAuthenticationService
-
 from zope.app.interfaces.security import IPrincipalRoleManager
-from zope.publisher.browser import TestRequest
+from zope.app.interfaces.security import IRoleService
 from zope.app.interfaces.services.service import ISimpleService
+from zope.app.browser.security.grants.principalroleview import PrincipalRoleView
+from zope.app.services.servicenames import Roles, Authentication
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.component import getServiceManager
 from zope.interface import implements
+from zope.publisher.browser import BrowserView, TestRequest
+
+class PrincipalRoleView(PrincipalRoleView, BrowserView):
+    """Adding BrowserView to Utilities; this is usually done by ZCML."""
 
 class DummySetting:
     def __init__(self, name):
@@ -99,8 +100,6 @@
             DummyAuthenticationService(principals = self._principals))
 
     def _makeOne(self):
-        from zope.app.browser.security.grants.principalroleview \
-             import PrincipalRoleView
         return PrincipalRoleView(DummyManager(), TestRequest())
 
     def testRoles(self):


=== Zope3/src/zope/app/browser/security/grants/tests/test_rolepermissionview.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/security/grants/tests/test_rolepermissionview.py:1.5	Wed Apr 30 19:37:55 2003
+++ Zope3/src/zope/app/browser/security/grants/tests/test_rolepermissionview.py	Thu Aug  7 13:41:00 2003
@@ -11,18 +11,29 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
+"""Role-Permission View Tests
+
+$Id$
+"""
 import unittest
 from zope.app.services.tests.placefulsetup\
            import PlacefulSetup
-from zope.component import getServiceManager
 from zope.app.services.servicenames import Roles, Permissions
 from zope.app.interfaces.security import IRoleService
 from zope.app.browser.security.grants.tests.roleservice import RoleService
-from zope.app.browser.security.grants.tests.permissionservice import PermissionService
-from zope.app.browser.security.grants.tests.rolepermissionmanager import RolePermissionManager
+from zope.app.browser.security.grants.tests.permissionservice import \
+     PermissionService
+from zope.app.browser.security.grants.tests.rolepermissionmanager import \
+     RolePermissionManager
 from zope.app.browser.security.grants.rolepermissionview \
      import RolePermissionView
 from zope.app.interfaces.security import IPermissionService
+from zope.component import getServiceManager
+from zope.publisher.browser import BrowserView, TestRequest
+
+class RolePermissionView(RolePermissionView, BrowserView):
+    """Adding BrowserView to Utilities; this is usually done by ZCML."""
+
 
 class Test(PlacefulSetup, unittest.TestCase):
 
@@ -67,14 +78,15 @@
         #         manager  member
         # read       +
         # write      .       -
-        REQ = {
+        env = {
             'p0': 'read', 'p1': 'write',
             'r0': 'manager', 'r1': 'member',
             'p0r0': 'Allow',
             'p1r0': 'Unset', 'p1r1': 'Deny',
+            'SUBMIT': 1
             }
-        self.view.request = REQ # XXX yuck
-        self.view.action(testing=1)
+        self.view.request = TestRequest(environ=env)        
+        self.view.update()
         permissionRoles = self.view.permissionRoles()
         for ip in range(len(permissionRoles)):
             permissionRole = permissionRoles[ip]
@@ -93,14 +105,15 @@
         #         manager  member
         # read       -
         # write      +
-        REQ = {
+        env = {
             'p0': 'read', 'p1': 'write',
             'r0': 'manager', 'r1': 'member',
             'p0r0': 'Deny',
-            'p1r0': 'Allow', 'p1r1': 'Unset'
+            'p1r0': 'Allow', 'p1r1': 'Unset',
+            'SUBMIT': 1
             }
-        self.view.request = REQ # XXX yuck
-        self.view.action(testing=1)
+        self.view.request = TestRequest(environ=env)        
+        self.view.update()
         permissionRoles = self.view.permissionRoles()
         for ip in range(len(permissionRoles)):
             permissionRole = permissionRoles[ip]
@@ -117,33 +130,38 @@
                     self.failUnless(setting == 'Unset')
 
     def testPermissionRoles(self):
-        self.view.update_permission(permission_id='write',
-                                    settings=['Allow', 'Unset'],
-                                    testing=1)
+        env={'permission_id': 'write',
+             'settings': ['Allow', 'Unset'],
+             'SUBMIT_PERMS': 1}
+        self.view.request = TestRequest(environ=env)        
+        self.view.update()
         permission = self.view.permissionForID('write')
         settings = permission.roleSettings()
         self.assertEquals(settings, ['Allow', 'Unset'])
 
 
-        self.view.update_permission(permission_id='write',
-                                    settings=['Unset', 'Deny'],
-                                    testing=1)
+        env={'permission_id': 'write',
+             'settings': ['Unset', 'Deny'],
+             'SUBMIT_PERMS': 1}
+        self.view.request = TestRequest(environ=env)        
+        self.view.update()
         permission = self.view.permissionForID('write')
         settings = permission.roleSettings()
         self.assertEquals(settings, ['Unset', 'Deny'])
 
-        self.assertRaises(ValueError,
-                          self.view.update_permission,
-                          permission_id='write',
-                          settings=['Unset', 'foo'],
-                          testing=1)
+        env={'permission_id': 'write',
+             'settings': ['Unset', 'foo'],
+             'SUBMIT_PERMS': 1}
+        self.view.request = TestRequest(environ=env)        
+        self.assertRaises(ValueError, self.view.update)
 
     def testRolePermissions(self):
-        REQ={'Allow': ['read'],
-             'Deny': ['write']}
-        self.view.request = REQ # XXX yuck
-        self.view.update_role(role_id='member',
-                              testing=1)
+        env={'Allow': ['read'],
+             'Deny': ['write'],
+             'SUBMIT_ROLE': 1,
+             'role_id': 'member'}
+        self.view.request = TestRequest(environ=env)
+        self.view.update(1)
         role = self.view.roleForID('member')
         pinfos = role.permissionsInfo()
         for pinfo in pinfos:
@@ -153,11 +171,12 @@
             if pid == 'write':
                 self.assertEquals(pinfo['setting'], 'Deny')
 
-        REQ={'Allow': [],
-             'Deny': ['read']}
-        self.view.request = REQ # XXX yuck
-        self.view.update_role(role_id='member',
-                              testing=1)
+        env={'Allow': [],
+             'Deny': ['read'],
+             'SUBMIT_ROLE': 1,
+             'role_id': 'member'}
+        self.view.request = TestRequest(environ=env)
+        self.view.update()
         role = self.view.roleForID('member')
         pinfos = role.permissionsInfo()
         for pinfo in pinfos:




More information about the Zope3-Checkins mailing list