diff options
| author | Bert JW Regeer <bertjw@regeer.org> | 2018-04-05 17:44:33 -0600 |
|---|---|---|
| committer | Bert JW Regeer <bertjw@regeer.org> | 2018-05-18 18:21:49 -0600 |
| commit | 12a58d211a7868337aaf5f040e7cd0c10e095c5b (patch) | |
| tree | 1db20e1c3256dc802c5577814b94753cc892d9e4 | |
| parent | 62dbd4554223e4980730c1fb459f5aaf8f946608 (diff) | |
| download | pyramid-12a58d211a7868337aaf5f040e7cd0c10e095c5b.tar.gz pyramid-12a58d211a7868337aaf5f040e7cd0c10e095c5b.tar.bz2 pyramid-12a58d211a7868337aaf5f040e7cd0c10e095c5b.zip | |
Replace MIMEAccept with acceptparse.create_accept_header
This is the new API that WebOb makes available and follows the
standards.
| -rw-r--r-- | pyramid/httpexceptions.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 734080434..718d51b50 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -133,7 +133,7 @@ from string import Template from zope.interface import implementer from webob import html_escape as _html_escape -from webob.acceptparse import MIMEAccept +from webob.acceptparse import create_accept_header from pyramid.compat import ( class_types, @@ -250,10 +250,12 @@ ${body}''') html_comment = '' comment = self.comment or '' accept_value = environ.get('HTTP_ACCEPT', '') - accept = MIMEAccept(accept_value) + accept = create_accept_header(accept_value) # Attempt to match text/html or application/json, if those don't # match, we will fall through to defaulting to text/plain - match = accept.best_match(['text/html', 'application/json']) + acceptable = accept.acceptable_offers(['text/html', 'application/json']) + acceptable = [offer[0] for offer in acceptable] + ['text/plain'] + match = acceptable[0] if match == 'text/html': self.content_type = 'text/html' |
