summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Merickel <github@m.merickel.org>2018-11-03 13:12:37 -0500
committerGitHub <noreply@github.com>2018-11-03 13:12:37 -0500
commitfc67869fb2732e715905614af3f9a69d48aed644 (patch)
tree05c3c6163ba096f8aeda882c25e4b405fce4423e /src
parentaa1660f3d9a5dc654a91544d72de596af2fdf9ba (diff)
parent0cef6bc5d627524354c47295df7a0aa84a64539e (diff)
downloadpyramid-fc67869fb2732e715905614af3f9a69d48aed644.tar.gz
pyramid-fc67869fb2732e715905614af3f9a69d48aed644.tar.bz2
pyramid-fc67869fb2732e715905614af3f9a69d48aed644.zip
Merge pull request #3411 from mmerickel/drop-media-ranges
remove deprecated media range support from add_view and add_route
Diffstat (limited to 'src')
-rw-r--r--src/pyramid/config/predicates.py4
-rw-r--r--src/pyramid/config/routes.py27
-rw-r--r--src/pyramid/config/views.py21
-rw-r--r--src/pyramid/predicates.py8
4 files changed, 16 insertions, 44 deletions
diff --git a/src/pyramid/config/predicates.py b/src/pyramid/config/predicates.py
index 8f16f74af..31e770562 100644
--- a/src/pyramid/config/predicates.py
+++ b/src/pyramid/config/predicates.py
@@ -197,9 +197,7 @@ class PredicateList(object):
return order, preds, phash.hexdigest()
-def normalize_accept_offer(offer, allow_range=False):
- if allow_range and '*' in offer:
- return offer.lower()
+def normalize_accept_offer(offer):
return str(Accept.parse_offer(offer))
diff --git a/src/pyramid/config/routes.py b/src/pyramid/config/routes.py
index a14662370..f9180bd76 100644
--- a/src/pyramid/config/routes.py
+++ b/src/pyramid/config/routes.py
@@ -247,6 +247,10 @@ class RoutesConfiguratorMixin(object):
:app:`Pyramid` 2.0. Use a list of specific media types to match
more than one type.
+ .. versionchanged:: 2.0
+
+ Removed support for media ranges.
+
effective_principals
If specified, this value should be a :term:`principal` identifier or
@@ -308,24 +312,11 @@ class RoutesConfiguratorMixin(object):
if accept is not None:
if not is_nonstr_iter(accept):
- if '*' in accept:
- warnings.warn(
- (
- 'Passing a media range to the "accept" argument '
- 'of Configurator.add_route is deprecated as of '
- 'Pyramid 1.10. Use a list of explicit media types.'
- ),
- DeprecationWarning,
- stacklevel=3,
- )
- # XXX switch this to False when range support is dropped
- accept = [normalize_accept_offer(accept, allow_range=True)]
-
- else:
- accept = [
- normalize_accept_offer(accept_option)
- for accept_option in accept
- ]
+ accept = [accept]
+ accept = [
+ normalize_accept_offer(accept_option)
+ for accept_option in accept
+ ]
# these are route predicates; if they do not match, the next route
# in the routelist will be tried
diff --git a/src/pyramid/config/views.py b/src/pyramid/config/views.py
index bd1b693ba..0c4a17376 100644
--- a/src/pyramid/config/views.py
+++ b/src/pyramid/config/views.py
@@ -116,7 +116,7 @@ class MultiView(object):
self.views[i] = (order, view, phash)
return
- if accept is None or '*' in accept:
+ if accept is None:
self.views.append((order, view, phash))
self.views.sort(key=operator.itemgetter(0))
else:
@@ -570,6 +570,10 @@ class ViewsConfiguratorMixin(object):
:app:`Pyramid` 2.0. Use explicit media types to avoid any
ambiguities in content negotiation.
+ .. versionchanged:: 2.0
+
+ Removed support for media ranges.
+
exception_only
.. versionadded:: 1.8
@@ -838,20 +842,7 @@ class ViewsConfiguratorMixin(object):
raise ConfigurationError(
'A list is not supported in the "accept" view predicate.'
)
- if '*' in accept:
- warnings.warn(
- (
- 'Passing a media range to the "accept" argument of '
- 'Configurator.add_view is deprecated as of '
- 'Pyramid 1.10. Use explicit media types to avoid '
- 'ambiguities in content negotiation that may impact '
- 'your users.'
- ),
- DeprecationWarning,
- stacklevel=4,
- )
- # XXX when media ranges are gone, switch allow_range=False
- accept = normalize_accept_offer(accept, allow_range=True)
+ accept = normalize_accept_offer(accept)
view = self.maybe_dotted(view)
context = self.maybe_dotted(context)
diff --git a/src/pyramid/predicates.py b/src/pyramid/predicates.py
index b95dfd9be..280f6c03c 100644
--- a/src/pyramid/predicates.py
+++ b/src/pyramid/predicates.py
@@ -133,15 +133,9 @@ class HeaderPredicate(object):
class AcceptPredicate(object):
- _is_using_deprecated_ranges = False
-
def __init__(self, values, config):
if not is_nonstr_iter(values):
values = (values,)
- # deprecated media ranges were only supported in versions of the
- # predicate that didn't support lists, so check it here
- if len(values) == 1 and '*' in values[0]:
- self._is_using_deprecated_ranges = True
self.values = values
def text(self):
@@ -150,8 +144,6 @@ class AcceptPredicate(object):
phash = text
def __call__(self, context, request):
- if self._is_using_deprecated_ranges:
- return self.values[0] in request.accept
return bool(request.accept.acceptable_offers(self.values))