[placement] replace deprecated accept.best_match
Webob has deprecated the best_match[1] method on accept headers and now spews warnings when it sees it. This change fixes it by using the equivalent (but more correct with regard to the relevant RFCs[2]) acceptable_offers[3] method. Existing unit tests in placement/test_util.py cover this change. [1] https://docs.pylonsproject.org/projects/webob/en/stable/api/webob.html#webob.acceptparse.AcceptValidHeader.best_match [2] https://tools.ietf.org/html/rfc7231#section-5.3.2 [3] https://docs.pylonsproject.org/projects/webob/en/stable/api/webob.html#webob.acceptparse.AcceptValidHeader.acceptable_offers Change-Id: Ie4d81fa178b3ed6b2a7b450b4978009486f07810 Closes-Bug: #1773225
This commit is contained in:
parent
ca7d23a3e7
commit
450444a782
|
@ -70,8 +70,8 @@ def check_accept(*types):
|
|||
@functools.wraps(f)
|
||||
def decorated_function(req):
|
||||
if req.accept:
|
||||
best_match = req.accept.best_match(types)
|
||||
if not best_match:
|
||||
best_matches = req.accept.acceptable_offers(types)
|
||||
if not best_matches:
|
||||
type_string = ', '.join(types)
|
||||
raise webob.exc.HTTPNotAcceptable(
|
||||
_('Only %(type)s is provided') % {'type': type_string},
|
||||
|
|
Loading…
Reference in New Issue