diff options
| author | Michael Merickel <michael@merickel.org> | 2018-10-10 02:09:49 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2018-10-10 02:09:49 -0500 |
| commit | 19eef8916cc556dffa3f9d48498bea869ee74b88 (patch) | |
| tree | 5fc7e3251abe4834960544792d903356280f71e1 | |
| parent | 0ddcb55c37770f1879490d25692ee644c754e67d (diff) | |
| download | pyramid-19eef8916cc556dffa3f9d48498bea869ee74b88.tar.gz pyramid-19eef8916cc556dffa3f9d48498bea869ee74b88.tar.bz2 pyramid-19eef8916cc556dffa3f9d48498bea869ee74b88.zip | |
use webob's new offer normalization
| -rw-r--r-- | pyramid/config/routes.py | 4 | ||||
| -rw-r--r-- | pyramid/config/util.py | 8 | ||||
| -rw-r--r-- | pyramid/config/views.py | 12 | ||||
| -rw-r--r-- | tox.ini | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/pyramid/config/routes.py b/pyramid/config/routes.py index 832fd3f8b..5d05429a7 100644 --- a/pyramid/config/routes.py +++ b/pyramid/config/routes.py @@ -318,8 +318,8 @@ class RoutesConfiguratorMixin(object): DeprecationWarning, stacklevel=3, ) - # XXX switch this to verify=True when range support is dropped - accept = [normalize_accept_offer(accept, verify=False)] + # XXX switch this to False when range support is dropped + accept = [normalize_accept_offer(accept, allow_range=True)] else: accept = [ diff --git a/pyramid/config/util.py b/pyramid/config/util.py index 8ebc8e45c..05d810f6f 100644 --- a/pyramid/config/util.py +++ b/pyramid/config/util.py @@ -221,10 +221,10 @@ class PredicateList(object): return order, preds, phash.hexdigest() -def normalize_accept_offer(offer, verify=True): - if verify: - Accept.parse_offer(offer) - return offer.lower() +def normalize_accept_offer(offer, allow_range=False): + if allow_range and '*' in offer: + return offer.lower() + return str(Accept.parse_offer(offer)) def sort_accept_offers(offers, order=None): diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 8d542a8a1..e6baa7c17 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -840,8 +840,8 @@ class ViewsConfiguratorMixin(object): DeprecationWarning, stacklevel=4, ) - # XXX when media ranges are gone, switch verify=True - accept = normalize_accept_offer(accept, verify=False) + # XXX when media ranges are gone, switch allow_range=False + accept = normalize_accept_offer(accept, allow_range=True) view = self.maybe_dotted(view) context = self.maybe_dotted(context) @@ -1308,12 +1308,12 @@ class ViewsConfiguratorMixin(object): 'cannot compare params across different media types') def normalize_types(thans): - thans = [normalize_accept_offer(o, verify=False) for o in thans] - for o in thans: - check_type(o) + thans = [normalize_accept_offer(than) for than in thans] + for than in thans: + check_type(than) return thans - value = normalize_accept_offer(value, verify=False) + value = normalize_accept_offer(value) offer_type, offer_subtype, offer_params = Accept.parse_offer(value) if weighs_more_than: @@ -26,7 +26,7 @@ extras = testing deps = - -egit+https://github.com/Pylons/webob.git@master#egg=webob + -egit+https://github.com/mmerickel/webob.git@accept-offer-object#egg=webob [testenv:py27-scaffolds] basepython = python2.7 |
