summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉric Araujo <earaujo@caravan.coop>2020-01-14 17:05:02 -0500
committerÉric Araujo <earaujo@caravan.coop>2020-01-14 17:05:02 -0500
commit04440d29082bbbae34fb76b9a8de083d1056e878 (patch)
treec09bfb13dfb3284bd0956539afbaf4f3c6791668
parent517140bac948e9a8bb60ad4c0c80bf45cd2741f1 (diff)
downloadpyramid-04440d29082bbbae34fb76b9a8de083d1056e878.tar.gz
pyramid-04440d29082bbbae34fb76b9a8de083d1056e878.tar.bz2
pyramid-04440d29082bbbae34fb76b9a8de083d1056e878.zip
apply more review fixes, minimize some diffs
-rw-r--r--docs/narr/urldispatch.rst21
-rw-r--r--docs/quick_tour.rst2
-rw-r--r--src/pyramid/config/routes.py10
-rw-r--r--src/pyramid/config/views.py4
4 files changed, 21 insertions, 16 deletions
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst
index c178dd4ce..83a186aea 100644
--- a/docs/narr/urldispatch.rst
+++ b/docs/narr/urldispatch.rst
@@ -1107,7 +1107,7 @@ See this code:
:linenos:
class AnyOfPredicate:
- def __init__(self, val):
+ def __init__(self, val, info):
self.segment_name = val[0]
self.allowed = tuple(val[0:])
@@ -1127,21 +1127,23 @@ See this code:
We register this class as a :term:`predicate factory` with the ``any_of`` keyword argument name.
Then we use that new keyword argument with :meth:`~pyramid.config.Configurator.add_route`.
-When the route is requested, Pyramid instantiates the ``AnyOfPredicate`` class using the value passed to the ``any_of``
-argument. The resulting instance is a :term:`predicate`. It will determine whether incoming requests satisfy its condition.
+When the route is requested, Pyramid instantiates the ``AnyOfPredicate`` class using the value passed to the ``any_of`` argument.
+The resulting instance is a :term:`predicate`.
+It will determine whether incoming requests satisfy its condition.
In the example above, a request for ``/three`` would match the route's URL pattern and satisfy the route's predicate
-because ``three`` is one of the allowed values, so the route would be matched. However a request for ``/millions`` will
+because ``three`` is one of the allowed values, so the route would be matched.
+However a request for ``/millions`` will
match the route's URL pattern but would not satisfy the route's predicate, and the route would not be matched.
-A custom route predicate may also *modify* the ``match`` dictionary.
-For instance, a predicate might do some type conversion of values:
+A custom route predicate may also *modify* the ``match`` dictionary. For
+instance, a predicate might do some type conversion of values:
.. code-block:: python
:linenos:
class IntegersPredicate:
- def __init__(self, val):
+ def __init__(self, val, info):
self.segment_names = val
def text(self):
@@ -1175,7 +1177,7 @@ expressions specifying requirements for that marker. For instance:
class IntegersPredicate:
- def __init__(self, val):
+ def __init__(self, val, info):
self.segment_names = val
def text(self):
@@ -1224,6 +1226,9 @@ route in a set of route predicates:
:linenos:
class TwentyTenPredicate:
+ def __init__(self, val, info):
+ pass
+
def text(self):
return "twenty_ten = True"
diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst
index 511868ade..49b61329e 100644
--- a/docs/quick_tour.rst
+++ b/docs/quick_tour.rst
@@ -483,7 +483,7 @@ more to offer:
.. seealso:: See also:
:ref:`Quick Tutorial View Classes <qtut_view_classes>`, :ref:`Quick
Tutorial More View Classes <qtut_more_view_classes>`, :ref:`class_as_view`,
- :ref:`view_and_route_predicates`.
+ and :ref:`view_and_route_predicates`.
Quick project startup with cookiecutters
diff --git a/src/pyramid/config/routes.py b/src/pyramid/config/routes.py
index 4077ec96b..78e708d1e 100644
--- a/src/pyramid/config/routes.py
+++ b/src/pyramid/config/routes.py
@@ -40,10 +40,10 @@ class RoutesConfiguratorMixin(object):
inherit_slash=None,
**predicates
):
- r""" Add a :term:`route configuration` to the current configuration state.
- The arguments to this method are divided into *predicate* and
- *non-predicate* types. :term:`Route predicate` arguments
- narrow the circumstances in which a route will be match a
+ """ Add a :term:`route configuration` to the current configuration
+ state. Arguments to ``add_route`` are divided into *predicate*
+ and *non-predicate* types. :term:`Route predicate` arguments
+ narrow the circumstances in which a route will match a
request; non-predicate arguments are informational.
Non-Predicate Arguments
@@ -301,7 +301,7 @@ class RoutesConfiguratorMixin(object):
:ref:`custom_route_predicates` for more information about
``info``.
- \*\*predicates
+ \\*\\*predicates
Pass extra keyword parameters to use custom predicates registered via
:meth:`pyramid.config.Configurator.add_route_predicate`. More than
diff --git a/src/pyramid/config/views.py b/src/pyramid/config/views.py
index bbc4fc5bc..c4fb54dd8 100644
--- a/src/pyramid/config/views.py
+++ b/src/pyramid/config/views.py
@@ -266,7 +266,7 @@ class ViewsConfiguratorMixin(object):
exception_only=False,
**view_options
):
- r""" Add a :term:`view configuration` to the current
+ """ Add a :term:`view configuration` to the current
configuration state. Arguments to ``add_view`` are broken
down below into *predicate* arguments and *non-predicate*
arguments. Predicate arguments narrow the circumstances in
@@ -739,7 +739,7 @@ class ViewsConfiguratorMixin(object):
obsoletes this argument, but it is kept around for backwards
compatibility.
- \*\*view_options
+ \\*\\*view_options
Pass extra keyword parameters to use custom predicates
or set a value for a view deriver. See