diff options
| -rw-r--r-- | pyramid/router.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pyramid/router.py b/pyramid/router.py index 99ea6ffa5..19773cf62 100644 --- a/pyramid/router.py +++ b/pyramid/router.py @@ -113,14 +113,21 @@ class Router(object): name=route.name, default=IRequest) - has_listeners and notify(BeforeTraversal(request)) - root_factory = route.factory or self.root_factory + # Notify anyone listening that we are about to start traversal + # + # Notify before creating root_factory in case we want to do something + # special on a route we may have matched. See + # https://github.com/Pylons/pyramid/pull/1876 for ideas of what is + # possible. + has_listeners and notify(BeforeTraversal(request)) + + # Create the root factory root = root_factory(request) attrs['root'] = root - # find a context + # We are about to traverse and find a context traverser = adapters.queryAdapter(root, ITraverser) if traverser is None: traverser = ResourceTreeTraverser(root) @@ -136,6 +143,9 @@ class Router(object): ) attrs.update(tdict) + + # Notify anyone listening that we have a context and traversal is + # complete has_listeners and notify(ContextFound(request)) # find a view callable |
