WebOb: Do not use the deprecated best_match method

Doing so requires WebOb >= 1.8.0 so that's updated

Change-Id: I5ddbc9244446afdd8e0fbe547967805de3e4071d
Closes-Bug: #1819752
This commit is contained in:
Cyril Roelandt 2019-03-12 19:48:06 +01:00 committed by Stephen Finucane
parent cf4d3b10ae
commit 0ed01983a7
5 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,5 @@
six>=1.9.0
WebOb>=1.2.3
WebOb>=1.8.0
simplegeneric
pytz
netaddr>=0.7.12

View File

@ -1,5 +1,5 @@
six>=1.9.0
WebOb>=1.2.3
WebOb>=1.8.0
simplegeneric
pytz
netaddr>=0.7.12

View File

@ -126,7 +126,7 @@ def media_type_accept(request, content_types):
"""
if request.method in ['GET', 'HEAD']:
if request.accept:
if request.accept.best_match(content_types):
if request.accept.acceptable_offers(content_types):
return True
error_message = ('Unacceptable Accept type: %s not in %s'
% (request.accept, content_types))

View File

@ -41,7 +41,11 @@ class RestProtocol(Protocol):
context.outformat = None
ext = os.path.splitext(request.path.split('/')[-1])[1]
inmime = request.content_type
outmime = request.accept.best_match(self.content_types)
try:
offers = request.accept.acceptable_offers(self.content_types)
outmime = offers[0][0]
except IndexError:
outmime = None
outformat = None
informat = None

View File

@ -317,7 +317,11 @@ class WSRoot(object):
# Attempt to correctly guess what content-type we should return.
ctypes = [ct for ct in protocol.content_types if ct]
if ctypes:
res_content_type = request.accept.best_match(ctypes)
try:
offers = request.accept.acceptable_offers(ctypes)
res_content_type = offers[0][0]
except IndexError:
res_content_type = None
# If not we will attempt to convert the body to an accepted
# output format.