diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-14 12:11:44 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-14 12:11:44 +0000 |
| commit | 70f1cda02f9acccf7ee1c8ad1a7ade36fba10dba (patch) | |
| tree | af2236494ee485c40575bb728d5755de1d579ace /repoze/bfg/configuration.py | |
| parent | 7edbac105bdde5cf27ea397343c748ec24b11bd8 (diff) | |
| download | pyramid-70f1cda02f9acccf7ee1c8ad1a7ade36fba10dba.tar.gz pyramid-70f1cda02f9acccf7ee1c8ad1a7ade36fba10dba.tar.bz2 pyramid-70f1cda02f9acccf7ee1c8ad1a7ade36fba10dba.zip | |
- 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.
Diffstat (limited to 'repoze/bfg/configuration.py')
| -rw-r--r-- | repoze/bfg/configuration.py | 17 |
1 files changed, 16 insertions, 1 deletions
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 |
