From 5e0a198348ed0056fd5127b024bc4ec76cd84b70 Mon Sep 17 00:00:00 2001 From: Atsushi Odagiri Date: Thu, 30 Jun 2011 20:24:37 +0900 Subject: add_route with root_route --- pyramid/config.py | 16 ++++++++++++++++ pyramid/tests/test_config.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pyramid/config.py b/pyramid/config.py index 934f56050..4143f5296 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -1550,6 +1550,22 @@ class Configurator(object): DeprecationWarning, 4) + def with_root_route(self, route_name): + mapper = self.get_routes_mapper() + route = mapper.get_route(route_name) + if route is None: + raise ConfigurationError + configurator = self.__class__(registry=self.registry, + package=self.package, + autocommit=self.autocommit, + root_route_name=route_name) + return configurator + + def mount(self, function, route_name): + function = self.maybe_dotted(function) + config = self.with_root_route(route_name) + function(config) + @action_method def add_route(self, name, diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 07d44f176..706170dcb 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -5326,4 +5326,4 @@ class DummyRegistry(object): def registerAdapter(self, *arg, **kw): self.adapters.append((arg, kw)) def queryAdapter(self, *arg, **kw): - return self.adaptation + return self.adaptation \ No newline at end of file -- cgit v1.2.3