Define errors_by_code in ipalib.errors

The errors_by_code mapping could be used in more places.  In
particular it will be useful in the Dogtag GSS-API authentication
effort.  Move to ipalib.errors.

Part of: https://pagure.io/freeipa/issue/5011

Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Fraser Tweedale 2017-03-06 12:03:44 +10:00
parent cc624fb178
commit c7766ebb94
2 changed files with 3 additions and 3 deletions

View File

@ -2016,5 +2016,7 @@ class GenericError(PublicError):
public_errors = tuple(sorted(
messages.iter_messages(globals(), PublicError), key=lambda E: E.errno))
errors_by_code = dict((e.errno, e) for e in public_errors)
if __name__ == '__main__':
messages.print_report('public errors', public_errors)

View File

@ -52,7 +52,7 @@ import six
from ipalib.backend import Connectible
from ipalib.constants import LDAP_GENERALIZED_TIME_FORMAT
from ipalib.errors import (public_errors, UnknownError, NetworkError,
from ipalib.errors import (errors_by_code, UnknownError, NetworkError,
XMLRPCMarshallError, JSONError)
from ipalib import errors, capabilities
from ipalib.request import context, Connection
@ -97,8 +97,6 @@ logger = logging.getLogger(__name__)
COOKIE_NAME = 'ipa_session'
CCACHE_COOKIE_KEY = 'X-IPA-Session-Cookie'
errors_by_code = dict((e.errno, e) for e in public_errors)
def update_persistent_client_session_data(principal, data):
'''