Merge "Fix best_match() deprecation warning"
This commit is contained in:
commit
22e8228dd4
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user