diff options
| author | Michael Merickel <michael@merickel.org> | 2019-10-03 13:49:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-03 13:49:08 -0500 |
| commit | 8ee8d8c589270b436ebfb8686f4e70d8aaa9e6f4 (patch) | |
| tree | 4b11916d73febccd1cbb59a793b77df8f979fefe /docs | |
| parent | be62391821676393b7ad5ab51655892e991c2ae0 (diff) | |
| parent | bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3 (diff) | |
| download | pyramid-8ee8d8c589270b436ebfb8686f4e70d8aaa9e6f4.tar.gz pyramid-8ee8d8c589270b436ebfb8686f4e70d8aaa9e6f4.tar.bz2 pyramid-8ee8d8c589270b436ebfb8686f4e70d8aaa9e6f4.zip | |
Merge pull request #3514 from mmerickel/predicate-info
define an IPredicateInfo instead of passing the full configurator to predicates
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/api/interfaces.rst | 21 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 16 |
2 files changed, 29 insertions, 8 deletions
diff --git a/docs/api/interfaces.rst b/docs/api/interfaces.rst index e542a6be0..08c67c385 100644 --- a/docs/api/interfaces.rst +++ b/docs/api/interfaces.rst @@ -109,3 +109,24 @@ Other Interfaces .. autointerface:: IViewDeriverInfo :members: + + .. autointerface:: IPredicateFactory + :members: + + .. autointerface:: IPredicateInfo + :members: + + .. autointerface:: IPredicate + :members: + + .. autointerface:: IRoutePredicate + :inherited-members: + :members: + + .. autointerface:: ISubscriberPredicate + :inherited-members: + :members: + + .. autointerface:: IViewPredicate + :inherited-members: + :members: diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 1ca5c3a6d..4a594a8c9 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -1482,7 +1482,7 @@ method. For example: :linenos: class ContentTypePredicate(object): - def __init__(self, val, config): + def __init__(self, val, info): self.val = val def text(self): @@ -1493,11 +1493,11 @@ method. For example: def __call__(self, context, request): return request.content_type == self.val -The constructor of a predicate factory takes two arguments: ``val`` and -``config``. The ``val`` argument will be the argument passed to -``view_config`` (or ``add_view``). In the example above, it will be the string -``File``. The second argument, ``config``, will be the Configurator instance -at the time of configuration. +The constructor of an :class:`pyramid.interfaces.IPredicateFactory`` takes two arguments: ``val`` and ``info``. +The ``val`` argument will be the argument passed to ``view_config`` (or ``add_view``). +In the example above, it will be the string ``File``. +The second argument, ``info``, will be an :class:`pyramid.interfaces.IPredicateInfo` instance created relative to the action configuring the predicate. +This means the ``info.package`` value is the package where the action is invoked passing in ``val`` and ``info.maybe_dotted`` is also relative to this package. The ``text`` method must return a string. It should be useful to describe the behavior of the predicate in error messages. @@ -1524,7 +1524,7 @@ a :term:`view predicate` or a :term:`route predicate`: performed using either the route's :term:`root factory` or the app's :term:`default root factory`. -In both cases the ``__call__`` method is expected to return ``True`` or +In all cases the ``__call__`` method is expected to return ``True`` or ``False``. It is possible to use the same predicate factory as both a view predicate and @@ -1560,7 +1560,7 @@ event type. :linenos: class RequestPathStartsWith(object): - def __init__(self, val, config): + def __init__(self, val, info): self.val = val def text(self): |
