예제 #1
0
def render_exception(error, user_locale=None):
    """Forms a WSGI response based on the current error."""
    body = {'error': {
        'code': error.code,
        'title': error.title,
        'message': unicode(gettextutils.get_localized_message(error.args[0],
                                                              user_locale)),
    }}
    if isinstance(error, exception.AuthPluginException):
        body['error']['identity'] = error.authentication
    return render_response(status=(error.code, error.title), body=body)
예제 #2
0
파일: wsgi.py 프로젝트: niuzhenguo/keystone
def render_exception(error, user_locale=None):
    """Forms a WSGI response based on the current error."""
    body = {'error': {
        'code': error.code,
        'title': error.title,
        'message': unicode(gettextutils.get_localized_message(error.args[0],
                                                              user_locale)),
    }}
    if isinstance(error, exception.AuthPluginException):
        body['error']['identity'] = error.authentication
    return render_response(status=(error.code, error.title), body=body)
예제 #3
0
def render_exception(error, user_locale=None):
    """Forms a WSGI response based on the current error."""
    body = {'error': {
        'code': error.code,
        'title': error.title,
        'message': unicode(gettextutils.get_localized_message(error.args[0],
                                                              user_locale)),
    }}
    headers = []
    if isinstance(error, exception.AuthPluginException):
        body['error']['identity'] = error.authentication
    elif isinstance(error, exception.Unauthorized):
        headers.append(('WWW-Authenticate',
                        'Keystone uri="%s"' % (
                            CONF.public_endpoint % CONF)))
    return render_response(status=(error.code, error.title),
                           body=body,
                           headers=headers)
예제 #4
0
def render_exception(error, user_locale=None):
    """Forms a WSGI response based on the current error."""
    body = {
        'error': {
            'code':
            error.code,
            'title':
            error.title,
            'message':
            unicode(
                gettextutils.get_localized_message(error.args[0],
                                                   user_locale)),
        }
    }
    headers = []
    if isinstance(error, exception.AuthPluginException):
        body['error']['identity'] = error.authentication
    elif isinstance(error, exception.Unauthorized):
        headers.append(('WWW-Authenticate',
                        'Keystone uri="%s"' % (CONF.public_endpoint % CONF)))
    return render_response(status=(error.code, error.title),
                           body=body,
                           headers=headers)