From 8b694da88f7f1b1aa244c72801b5effa43538056 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 30 Jun 2010 18:50:39 +0000 Subject: document return value --- docs/narr/urldispatch.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs/narr') diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index c6bc1df2d..2f96ca26c 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -624,6 +624,7 @@ For instance, a predicate might do some type conversion of values: match[segment_name] = int(match[segment_name]) except (TypeError, ValueError): pass + return True return predicate ymd_to_int = integers('year', 'month', 'day') @@ -631,6 +632,11 @@ For instance, a predicate might do some type conversion of values: config.add_route('num', '/:year/:month/:day', custom_predicates=(ymd_to_int,)) +Note that a conversion predicate is still a predicate so it must +return ``True`` or ``False``; a predicate that does *only* conversion, +such as the one we demonstrate above should unconditionally return +``True``. + The ``match`` dictionary passed within ``info`` to each predicate attached to a route will be the same dictionary. Therefore, when registering a custom predicate which modifies the ``match`` dict, the -- cgit v1.2.3