From bdee24fc37e07dcbbe3380bc16b48c66afd0e8c3 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 30 Sep 2019 22:02:03 -0500 Subject: fix predicate signatures --- docs/narr/hooks.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/narr/hooks.rst') 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): -- cgit v1.2.3