From 70f1cda02f9acccf7ee1c8ad1a7ade36fba10dba Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 14 Sep 2010 12:11:44 +0000 Subject: - The ``add_route`` method of a Configurator now accepts a ``pregenerator`` argument. The pregenerator for the resulting route is called by ``route_url`` in order to adjust the set of arguments passed to it by the user for special purposes, such as Pylons 'subdomain' support. It will influence the URL returned by ``route_url``. See the ``repoze.bfg.interfaces.IRoutePregenerator`` interface for more information. --- repoze/bfg/configuration.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'repoze/bfg/configuration.py') diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index e4ac824ef..f0c26cc3b 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -1072,6 +1072,7 @@ class Configurator(object): view_attr=None, use_global_views=False, path=None, + pregenerator=None, _info=u''): """ Add a :term:`route configuration` to the current configuration state, as well as possibly a :term:`view @@ -1145,6 +1146,19 @@ class Configurator(object): .. note:: This feature is new as of :mod:`repoze.bfg` 1.3. + pregenerator + + This option should be a callable object that implements the + :class:`repoze.bfg.interfaces.IRoutePregenerator` + interface. A :term:`pregenerator` is a callable called by + the :mod:`repoze.bfg.url.route_url` function to augment or + replace the arguments it is passed when generating a URL + for the route. This is a feature not often used directly + by applications, it is meant to be hooked by frameworks + that use :mod:`repoze.bfg` as a base. + + .. note:: This feature is new as of :mod:`repoze.bfg` 1.3. + Predicate Arguments pattern @@ -1391,7 +1405,8 @@ class Configurator(object): pattern = path if pattern is None: raise ConfigurationError('"pattern" argument may not be None') - return mapper.connect(name, pattern, factory, predicates=predicates) + return mapper.connect(name, pattern, factory, predicates=predicates, + pregenerator=pregenerator) def get_routes_mapper(self): """ Return the :term:`routes mapper` object associated with -- cgit v1.2.3