diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-07-04 08:52:47 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-09-03 18:16:12 +0200 |
commit | a95eaeac8e07b8ccd173b0f408575cc9a0d508fc (patch) | |
tree | 6cd7e09e02d313a3d382d1efbb27588aab27a866 /ipalib/plugins/baseldap.py | |
parent | 4f03aed5e603389bbb149464eee597180470ad70 (diff) | |
download | freeipa-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/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 5805ba9b7..3dcb2d39f 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -194,7 +194,8 @@ def validate_del_attribute(ugettext, attr): def validate_attribute(ugettext, name, attr): m = re.match("\s*(.*?)\s*=\s*(.*?)\s*$", attr) if not m or len(m.groups()) != 2: - raise errors.ValidationError(name=name, error='Invalid format. Should be name=value') + raise errors.ValidationError( + name=name, error=_('Invalid format. Should be name=value')) def get_effective_rights(ldap, dn, attrs=None): assert isinstance(dn, DN) @@ -690,16 +691,22 @@ def _check_limit_object_class(attributes, attrs, allow_only): for (oid, attr) in attributes[0].iteritems(): if attr.names[0].lower() in limitattrs: if not allow_only: - raise errors.ObjectclassViolation(info='attribute "%(attribute)s" not allowed' % dict(attribute=attr.names[0].lower())) + raise errors.ObjectclassViolation( + info=_('attribute "%(attribute)s" not allowed') % dict( + attribute=attr.names[0].lower())) limitattrs.remove(attr.names[0].lower()) # And now the MAY for (oid, attr) in attributes[1].iteritems(): if attr.names[0].lower() in limitattrs: if not allow_only: - raise errors.ObjectclassViolation(info='attribute "%(attribute)s" not allowed' % dict(attribute=attr.names[0].lower())) + raise errors.ObjectclassViolation( + info=_('attribute "%(attribute)s" not allowed') % dict( + attribute=attr.names[0].lower())) limitattrs.remove(attr.names[0].lower()) if len(limitattrs) > 0 and allow_only: - raise errors.ObjectclassViolation(info='attribute "%(attribute)s" not allowed' % dict(attribute=limitattrs[0])) + raise errors.ObjectclassViolation( + info=_('attribute "%(attribute)s" not allowed') % dict( + attribute=limitattrs[0])) class CallbackInterface(Method): @@ -882,8 +889,7 @@ last, after all sets and adds."""), try: entry_attrs[attr].remove(delval) except ValueError: - raise errors.AttrValueNotFound(attr=attr, - value=delval) + raise errors.AttrValueNotFound(attr=attr, value=delval) if needldapattrs: try: |