summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/hbacrule.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-07-04 08:52:47 -0400
committerMartin Kosek <mkosek@redhat.com>2012-09-03 18:16:12 +0200
commita95eaeac8e07b8ccd173b0f408575cc9a0d508fc (patch)
tree6cd7e09e02d313a3d382d1efbb27588aab27a866 /ipalib/plugins/hbacrule.py
parent4f03aed5e603389bbb149464eee597180470ad70 (diff)
downloadfreeipa-a95eaeac8e07b8ccd173b0f408575cc9a0d508fc.tar.gz
freeipa-a95eaeac8e07b8ccd173b0f408575cc9a0d508fc.tar.xz
freeipa-a95eaeac8e07b8ccd173b0f408575cc9a0d508fc.zip
Internationalization for public errors
Currently, we throw many public exceptions without proper i18n. Wrap natural-language error messages in _() so they can be translated. In the service plugin, raise NotFound errors using handle_not_found helper so the error message contains the offending service. Use ScriptError instead of NotFoundError in bindinstance install. https://fedorahosted.org/freeipa/ticket/1953
Diffstat (limited to 'ipalib/plugins/hbacrule.py')
-rw-r--r--ipalib/plugins/hbacrule.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ipalib/plugins/hbacrule.py b/ipalib/plugins/hbacrule.py
index 94f0d0e20..0b1e8b83c 100644
--- a/ipalib/plugins/hbacrule.py
+++ b/ipalib/plugins/hbacrule.py
@@ -446,7 +446,8 @@ class hbacrule_add_user(LDAPAddMember):
self.obj.handle_not_found(*keys)
if 'usercategory' in entry_attrs and \
entry_attrs['usercategory'][0].lower() == 'all':
- raise errors.MutuallyExclusiveError(reason="users cannot be added when user category='all'")
+ raise errors.MutuallyExclusiveError(
+ reason=_("users cannot be added when user category='all'"))
return dn
api.register(hbacrule_add_user)
@@ -475,7 +476,8 @@ class hbacrule_add_host(LDAPAddMember):
self.obj.handle_not_found(*keys)
if 'hostcategory' in entry_attrs and \
entry_attrs['hostcategory'][0].lower() == 'all':
- raise errors.MutuallyExclusiveError(reason="hosts cannot be added when host category='all'")
+ raise errors.MutuallyExclusiveError(
+ reason=_("hosts cannot be added when host category='all'"))
return dn
api.register(hbacrule_add_host)
@@ -504,7 +506,8 @@ class hbacrule_add_sourcehost(LDAPAddMember):
self.obj.handle_not_found(*keys)
if 'sourcehostcategory' in entry_attrs and \
entry_attrs['sourcehostcategory'][0].lower() == 'all':
- raise errors.MutuallyExclusiveError(reason="source hosts cannot be added when sourcehost category='all'")
+ raise errors.MutuallyExclusiveError(reason=_(
+ "source hosts cannot be added when sourcehost category='all'"))
return add_external_pre_callback('host', ldap, dn, keys, options)
def post_callback(self, ldap, completed, failed, dn, entry_attrs, *keys, **options):
@@ -541,7 +544,8 @@ class hbacrule_add_service(LDAPAddMember):
self.obj.handle_not_found(*keys)
if 'servicecategory' in entry_attrs and \
entry_attrs['servicecategory'][0].lower() == 'all':
- raise errors.MutuallyExclusiveError(reason="services cannot be added when service category='all'")
+ raise errors.MutuallyExclusiveError(reason=_(
+ "services cannot be added when service category='all'"))
return dn
api.register(hbacrule_add_service)