diff options
| author | Atsushi Odagiri <aodagx@gmail.com> | 2011-06-30 20:24:37 +0900 |
|---|---|---|
| committer | Atsushi Odagiri <aodagx@gmail.com> | 2011-07-03 03:11:05 +0900 |
| commit | 5e0a198348ed0056fd5127b024bc4ec76cd84b70 (patch) | |
| tree | 612ce3f813f4f3b66b2225166d6744da8e4db4ac | |
| parent | 16cf0201039d26b180db7109dda77bd2c9850e9d (diff) | |
| download | pyramid-5e0a198348ed0056fd5127b024bc4ec76cd84b70.tar.gz pyramid-5e0a198348ed0056fd5127b024bc4ec76cd84b70.tar.bz2 pyramid-5e0a198348ed0056fd5127b024bc4ec76cd84b70.zip | |
add_route with root_route
| -rw-r--r-- | pyramid/config.py | 16 | ||||
| -rw-r--r-- | pyramid/tests/test_config.py | 2 |
2 files changed, 17 insertions, 1 deletions
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 |
