diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/urldispatch.rst | 6 |
1 files changed, 6 insertions, 0 deletions
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 |
