wsgi call to best_match() generates the following warning: DeprecationWarning: The behavior of AcceptValidHeader.best_match is currently being maintained for backward compatibility, but it will be deprecated in the future, as it does not conform to the RFC. Change to use acceptable_offers() as was done in nova code. Simlar changes in the wsgi best language code as well, except new call is to lookup(). Required bump to get WebOb 1.8.2. Trivialfix Change-Id: I45a222c098658eef6a49adcc168b0f5625ea49db
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
# Copyright (c) 2015 Mirantis, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from neutron_lib.api import faults
|
|
import oslo_i18n
|
|
from oslo_log import log as logging
|
|
from pecan import hooks
|
|
|
|
from neutron.api import api_common
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class ExceptionTranslationHook(hooks.PecanHook):
|
|
def on_error(self, state, e):
|
|
language = None
|
|
if state.request.accept_language:
|
|
all_languages = oslo_i18n.get_available_languages('neutron')
|
|
language = state.request.accept_language.lookup(all_languages,
|
|
default='fake_LANG')
|
|
if language == 'fake_LANG':
|
|
language = None
|
|
exc = api_common.convert_exception_to_http_exc(e, faults.FAULT_MAP,
|
|
language)
|
|
if hasattr(exc, 'code') and 400 <= exc.code < 500:
|
|
LOG.info('%(action)s failed (client error): %(exc)s',
|
|
{'action': state.request.method, 'exc': exc})
|
|
else:
|
|
LOG.exception('%s failed.', state.request.method)
|
|
return exc
|