[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/ Fixed issue #298:
Role/permission title and description should be messageids
Dmitry Vasiliev
dima at hlabs.spb.ru
Wed Jul 27 09:28:47 EDT 2005
Log message for revision 37478:
Fixed issue #298: Role/permission title and description should be messageids
Changed:
U Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
U Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/ftests.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/rolepermissionview.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
===================================================================
--- Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt 2005-07-27 13:24:19 UTC (rev 37477)
+++ Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt 2005-07-27 13:28:47 UTC (rev 37478)
@@ -10,6 +10,9 @@
Bug Fixes
+ - Fixed issue 298 (Role/permission title and description
+ should be messageids)
+
- Several fixes were backported from the Zope 2.8 integration
branch, making the main X3.0 line compatible with Zope 2.8 and
thus allowing X3.0 releases to be included into Zope 2.8
@@ -387,7 +390,7 @@
- Write generic get/queryType(object, type) that returns the interface of
the 'object' that provides 'type'.
-
+
- Implemented Permission Redefinition portion of ZCMLEnhancements.
- Implemented http://dev.zope.org/Zope3/MinimalDefaultViewDirectives
@@ -646,7 +649,7 @@
o Made Zope-specific Vocabulary Registry use utilities. The vocabulary
directive now registers vocabulary factories as utilities.
-
+
o Roles are now stored as utilities. While doing this, I also schemafied
the IRole interface to use 'id', 'title', 'description' instead of
'getId()', 'getTitle()' and 'getDescription()'. This was done for
@@ -670,7 +673,7 @@
translate(location, msgid, domain=None, mapping=None, context=None,
target_language=None, default=None):
-
+
o The Factory Service was removed and factories became utilities. The
'getFactoryInterfaces()' and 'createObject()' functions are still
available via 'zope.app.zapi'. I also added the 'getFactoriesFor()'
@@ -741,12 +744,12 @@
- Gave many class and function doc strings some meaning, including some
that just contained XXX statements. Many more files exist that have
meaningless or incomplete doc strings.
-
+
- Removed unused imports.
- Removed the simple local authentication service
zope.app.services.auth. It was deprecated for a while already.
-
+
- Removed all fixup entries in zope/app/backward.zcml. backward.zcml was
not included anywhere anyways, so that this should not pose a
problem. Removed all fixup code as well.
@@ -874,7 +877,7 @@
- Introspector uses the Interface service now, instead of the ++module++
namespace.
-
+
- Refactoring and cleanup of the schema/form code.
- Improvements to the OnlineHelp, which has been deactivated for this
@@ -889,7 +892,7 @@
- Various improvements to ZConfig
-
+
Miscellaneous
- Progress with the TUV-IT security accredidation
@@ -1048,7 +1051,7 @@
Amaya).
- Partial WebDAV support
-
+
- A basic workflow system
- Improvements to Zope 3 schemas and form generation
@@ -1166,5 +1169,3 @@
- FTP support (not sure if this works)
- XML-RPC support (not sure if this works)
-
-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/ftests.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/ftests.py 2005-07-27 13:24:19 UTC (rev 37477)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/ftests.py 2005-07-27 13:28:47 UTC (rev 37478)
@@ -16,7 +16,13 @@
$Id: ftests.py 25177 2004-06-02 13:17:31Z jim $
"""
import unittest
+
from zope.app.tests.functional import BrowserTestCase
+from zope.app.security.interfaces import IPermission
+from zope.app.security.permission import Permission
+from zope.app.securitypolicy.role import Role
+from zope.app.securitypolicy.interfaces import IRole
+from zope.app.tests import ztapi
class GrantTest(BrowserTestCase):
@@ -89,6 +95,44 @@
self.checkForBrokenLinks(body, '/@@RolesPermissions.html',
'mgr:mgrpw')
+ def testAllRolePermissionsFormForLocalRoles(self):
+ role = Role(u"id", u"Local Role")
+ ztapi.provideUtility(IRole, role)
+ self.testAllRolePermissions()
+
+ response = self.publish(
+ '/@@AllRolePermissions.html',
+ basic='mgr:mgrpw')
+ body = response.getBody()
+ self.assert_('Local Role' in body)
+
+ def testAllRolePermissionsFormForLocalPermissions(self):
+ permission = Permission(u"id", u"Local Permission")
+ ztapi.provideUtility(IPermission, permission)
+ self.testAllRolePermissions()
+
+ response = self.publish(
+ '/@@AllRolePermissions.html',
+ basic='mgr:mgrpw')
+ body = response.getBody()
+ self.assert_('Local Permission' in body)
+
+ def testRolesWithPermissionsFormForLocalPermission(self):
+ permission = Permission(u"id", u"Local Permission")
+ ztapi.provideUtility(IPermission, permission)
+
+ response = self.publish(
+ '/@@AllRolePermissions.html',
+ form={'role_id': 'zope.Manager',
+ 'Allow': ['id'],
+ 'Deny': ['id'],
+ 'SUBMIT_ROLE': 'Save Changes'},
+ basic='mgr:mgrpw',
+ handle_errors=True)
+ body = response.getBody()
+ self.assert_('You choose both allow and deny for permission'
+ ' "Local Permission". This is not allowed.' in body)
+
_result = '''\
<option value="Unset"> </option>
<option value="Allow" selected="selected">+</option>
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/rolepermissionview.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/rolepermissionview.py 2005-07-27 13:24:19 UTC (rev 37477)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/securitypolicy/browser/rolepermissionview.py 2005-07-27 13:28:47 UTC (rev 37478)
@@ -27,13 +27,15 @@
from zope.app.security.interfaces import IPermission
from zope.app.securitypolicy.interfaces import IRole, IRolePermissionManager
+
class RolePermissionView(object):
def roles(self):
roles = getattr(self, '_roles', None)
if roles is None:
roles = [
- (translate(role.title, context=self.request).strip(), role)
+ (translate(role.title, context=self.request,
+ default=role.title).strip(), role)
for name, role in zapi.getUtilitiesFor(IRole)]
roles.sort()
roles = self._roles = [role for name, role in roles]
@@ -43,15 +45,13 @@
permissions = getattr(self, '_permissions', None)
if permissions is None:
permissions = [
- (translate(perm.title, context=self.request).strip(), perm)
+ (translate(perm.title, context=self.request,
+ default=perm.title).strip(), perm)
for name, perm in zapi.getUtilitiesFor(IPermission)
if name != 'zope.Public']
permissions.sort()
-
-
permissions = self._permissions = [perm
for name, perm in permissions]
-
return permissions
def availableSettings(self, noacquire=False):
@@ -137,9 +137,10 @@
rperm = permission.id
if rperm in allowed and rperm in denied:
raise UserError(
- 'You chose both allow and deny for permission "%s". '
+ 'You choose both allow and deny for permission "%s". '
'This is not allowed.'
- % translate(permission.title, context=self.request)
+ % translate(permission.title, context=self.request,
+ default=permission.title)
)
if rperm in allowed:
prm.grantPermissionToRole(rperm, role_id)
@@ -229,4 +230,3 @@
'title': permission.title,
'setting': settings.get(permission.id, nosetting)}
for permission in self._permissions]
-
More information about the Zope3-Checkins
mailing list