diff options
author | Zuul <zuul@review.openstack.org> | 2018-10-04 23:33:23 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-10-04 23:33:23 +0000 |
commit | 22e8228dd419c0179bcf2f895ce32a0ebc587d46 (patch) | |
tree | 7ebe339f77a30b1f07b77dc63737b82cfab87125 | |
parent | 8056f2b386ca07f319907e9cf79124eca5510f12 (diff) | |
parent | bc4f93c232d1a608ae88fa027371755bed54b3ca (diff) | |
download | neutron-22e8228dd419c0179bcf2f895ce32a0ebc587d46.tar.gz |
Merge "Fix best_match() deprecation warning"
-rw-r--r-- | lower-constraints.txt | 2 | ||||
-rw-r--r-- | neutron/pecan_wsgi/hooks/translation.py | 7 | ||||
-rw-r--r-- | neutron/wsgi.py | 12 | ||||
-rw-r--r-- | requirements.txt | 2 |
4 files changed, 16 insertions, 7 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt index c27ddbbbda..ea8086d585 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -147,6 +147,6 @@ unittest2==1.1.0 vine==1.1.4 waitress==1.1.0 weakrefmethod==1.0.2 -WebOb==1.7.1 +WebOb==1.8.2 WebTest==2.0.27 wrapt==1.7.0 diff --git a/neutron/pecan_wsgi/hooks/translation.py b/neutron/pecan_wsgi/hooks/translation.py index 1b97712f3a..7619fca86b 100644 --- a/neutron/pecan_wsgi/hooks/translation.py +++ b/neutron/pecan_wsgi/hooks/translation.py @@ -28,8 +28,11 @@ class ExceptionTranslationHook(hooks.PecanHook): def on_error(self, state, e): language = None if state.request.accept_language: - language = state.request.accept_language.best_match( - oslo_i18n.get_available_languages('neutron')) + 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: diff --git a/neutron/wsgi.py b/neutron/wsgi.py index ef04f1965c..14d4805dc5 100644 --- a/neutron/wsgi.py +++ b/neutron/wsgi.py @@ -249,8 +249,10 @@ class Request(wsgi.Request): ctypes = ['application/json'] # Finally search in Accept-* headers - bm = self.accept.best_match(ctypes) - return bm or 'application/json' + acceptable = self.accept.acceptable_offers(ctypes) + if acceptable: + return acceptable[0][0] + return 'application/json' def get_content_type(self): allowed_types = ("application/json",) @@ -271,7 +273,11 @@ class Request(wsgi.Request): if not self.accept_language: return None all_languages = oslo_i18n.get_available_languages('neutron') - return self.accept_language.best_match(all_languages) + best_match = self.accept_language.lookup(all_languages, + default='fake_LANG') + if best_match == 'fake_LANG': + best_match = None + return best_match @property def context(self): diff --git a/requirements.txt b/requirements.txt index c4d1501f88..6519b9a7c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ python-neutronclient>=6.7.0 # Apache-2.0 tenacity>=3.2.1 # Apache-2.0 ryu>=4.24 # Apache-2.0 SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.2.0 # MIT -WebOb>=1.7.1 # MIT +WebOb>=1.8.2 # MIT keystoneauth1>=3.4.0 # Apache-2.0 alembic>=0.8.10 # MIT six>=1.10.0 # MIT |