[Zope3-checkins] SVN: Zope3/trunk/ Fixed issue #298:
Role/permission title and description should be messageids
Dmitry Vasiliev
dima at hlabs.spb.ru
Wed Jul 27 10:16:29 EDT 2005
Log message for revision 37484:
Fixed issue #298: Role/permission title and description should be messageids
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/doc/TODO.txt
U Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
U Zope3/trunk/src/zope/i18n/__init__.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-07-27 14:12:53 UTC (rev 37483)
+++ Zope3/trunk/doc/CHANGES.txt 2005-07-27 14:16:29 UTC (rev 37484)
@@ -650,6 +650,8 @@
Bug Fixes
+ - Fix #298: Role/permission title and description should be messageids
+
- Fix #316: Zope3 test.py truncates path with dir=
- Fix #332 : Death to IContentContainer
Modified: Zope3/trunk/doc/TODO.txt
===================================================================
--- Zope3/trunk/doc/TODO.txt 2005-07-27 14:12:53 UTC (rev 37483)
+++ Zope3/trunk/doc/TODO.txt 2005-07-27 14:16:29 UTC (rev 37484)
@@ -27,8 +27,6 @@
* 296: missing display widgets
- * 298: Role/permission title and description should be messageids
-
* 307: browser:addMenuItem and broken view references
* 336: zpkg: defining 'zpkgsetup' resource shouldn't be necessary
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py 2005-07-27 14:12:53 UTC (rev 37483)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py 2005-07-27 14:16:29 UTC (rev 37484)
@@ -16,8 +16,15 @@
$Id$
"""
import unittest
+
from zope.app.testing import functional
+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 RolePermissionsTest(functional.BrowserTestCase):
def testAllRolePermissionsForm(self):
@@ -78,6 +85,44 @@
self.checkForBrokenLinks(body, '/++etc++site/@@RolesPermissions.html',
'mgr:mgrpw')
+ def testAllRolePermissionsFormForLocalRoles(self):
+ role = Role(u"id", u"Local Role")
+ ztapi.provideUtility(IRole, role)
+ self.testAllRolePermissions()
+
+ response = self.publish(
+ '/++etc++site/@@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(
+ '/++etc++site/@@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(
+ '/++etc++site/@@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/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py 2005-07-27 14:12:53 UTC (rev 37483)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py 2005-07-27 14:16:29 UTC (rev 37484)
@@ -33,7 +33,7 @@
roles = getattr(self, '_roles', None)
if roles is None:
roles = [
- (translate(role.title, context=self.request, default=role.title).strip(), role)
+ (translate(role.title, context=self.request).strip(), role)
for name, role in zapi.getUtilitiesFor(IRole)]
roles.sort()
roles = self._roles = [role for name, role in roles]
@@ -47,8 +47,6 @@
for name, perm in zapi.getUtilitiesFor(IPermission)
if name != 'zope.Public']
permissions.sort()
-
-
permissions = self._permissions = [perm
for name, perm in permissions]
@@ -137,7 +135,7 @@
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)
)
@@ -229,4 +227,3 @@
'title': permission.title,
'setting': settings.get(permission.id, nosetting)}
for permission in self._permissions]
-
Modified: Zope3/trunk/src/zope/i18n/__init__.py
===================================================================
--- Zope3/trunk/src/zope/i18n/__init__.py 2005-07-27 14:12:53 UTC (rev 37483)
+++ Zope3/trunk/src/zope/i18n/__init__.py 2005-07-27 14:16:29 UTC (rev 37484)
@@ -17,11 +17,13 @@
"""
import re
import warnings
+
from zope.component import queryUtility
from zope.i18nmessageid import MessageIDFactory, MessageID
from zope.i18nmessageid import MessageFactory, Message
from zope.i18n.interfaces import ITranslationDomain
+
# Set up regular expressions for finding interpolation variables in text.
# NAME_RE must exactly match the expression of the same name in the
# zope.tal.taldefs module:
@@ -30,17 +32,17 @@
_interp_regex = re.compile(r'(?<!\$)(\$(?:%(n)s|{%(n)s}))' %({'n': NAME_RE}))
_get_var_regex = re.compile(r'%(n)s' %({'n': NAME_RE}))
-
def _translate(msgid, domain=None, mapping=None, context=None,
target_language=None, default=None):
if isinstance(msgid, (MessageID, Message)):
domain = msgid.domain
default = msgid.default
- if default is None:
- default = msgid
mapping = msgid.mapping
+ if default is None:
+ default = msgid
+
util = queryUtility(ITranslationDomain, domain)
if util is None:
More information about the Zope3-Checkins
mailing list