diff options
| author | Michael Merickel <michael@merickel.org> | 2019-09-30 22:02:03 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2019-10-02 10:03:22 -0500 |
| commit | bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3 (patch) | |
| tree | 4b11916d73febccd1cbb59a793b77df8f979fefe | |
| parent | 52779768030ec58407db2586b0f83683ffd180f0 (diff) | |
| download | pyramid-bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3.tar.gz pyramid-bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3.tar.bz2 pyramid-bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3.zip | |
fix predicate signatures
| -rw-r--r-- | docs/narr/hooks.rst | 16 |
1 files changed, 8 insertions, 8 deletions
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): |
