diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-08 04:43:05 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-08 04:43:05 +0000 |
| commit | 49eccc078d13e1b6104f201f7e11ac31d8e024cf (patch) | |
| tree | ecfff3c386b11082d4d3427f61c68c366f8ace70 /repoze/bfg/configuration.py | |
| parent | 74409d12f7eb085bc992a200cc74799e4d1ff355 (diff) | |
| download | pyramid-49eccc078d13e1b6104f201f7e11ac31d8e024cf.tar.gz pyramid-49eccc078d13e1b6104f201f7e11ac31d8e024cf.tar.bz2 pyramid-49eccc078d13e1b6104f201f7e11ac31d8e024cf.zip | |
- Add an API to the ``Configurator`` named ``get_routes_mapper``.
This returns an object implementing the ``IRoutesMapper`` interface.
Diffstat (limited to 'repoze/bfg/configuration.py')
| -rw-r--r-- | repoze/bfg/configuration.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index 962ba8f25..5a97c4f38 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -1338,10 +1338,8 @@ class Configurator(object): _info=_info, ) - mapper = self.registry.queryUtility(IRoutesMapper) - if mapper is None: - mapper = RoutesMapper() - self.registry.registerUtility(mapper, IRoutesMapper) + mapper = self.get_routes_mapper() + factory = self.maybe_dotted(factory) if pattern is None: pattern = path @@ -1349,6 +1347,15 @@ class Configurator(object): raise ConfigurationError('"pattern" argument may not be None') return mapper.connect(name, pattern, factory, predicates=predicates) + def get_routes_mapper(self): + """ Return the :term:`routes mapper` object associated with + this configurator's :term:`registry`.""" + mapper = self.registry.queryUtility(IRoutesMapper) + if mapper is None: + mapper = RoutesMapper() + self.registry.registerUtility(mapper, IRoutesMapper) + return mapper + def scan(self, package=None, categories=None, _info=u''): """ Scan a Python package and any of its subpackages for objects marked with :term:`configuration decoration` such as |
