diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-25 20:52:35 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-25 20:52:35 +0000 |
| commit | 8cfe7068783a3520aa3bc09f260502d002e9ac60 (patch) | |
| tree | a05a4b50ce747cfef448ef795b349d0128601549 /repoze/bfg/traversal.py | |
| parent | a6e0463027dee43c6aac487a9ea8bb844b1e8add (diff) | |
| download | pyramid-8cfe7068783a3520aa3bc09f260502d002e9ac60.tar.gz pyramid-8cfe7068783a3520aa3bc09f260502d002e9ac60.tar.bz2 pyramid-8cfe7068783a3520aa3bc09f260502d002e9ac60.zip | |
- The ``repoze.bfg.urldispatch.RoutesRootFactory`` now injects the
``wsgiorg.routing_args`` environment variable into the environ when
a route matches. This is a tuple of ((), routing_args) where
routing_args is the value that comes back from the routes mapper
match (the "match dict").
- The ``repoze.bfg.traversal.RoutesModelTraverser`` class now wants to
obtain the ``view_name`` and ``subpath`` from the
``wsgiorgs.routing_args`` environment variable. It falls back to
obtaining these from the context for backwards compatibility.
Diffstat (limited to 'repoze/bfg/traversal.py')
| -rw-r--r-- | repoze/bfg/traversal.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index d3befe86c..2d56f9302 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -172,9 +172,28 @@ class RoutesModelTraverser(object): self.context = context def __call__(self, environ): - view_name = getattr(self.context, 'controller', None) # b/w compat<0.6.3 - if view_name is None: - view_name = getattr(self.context, 'view_name', '') # 0.6.3+ - subpath = getattr(self.context, 'subpath', '') # 0.6.3+ - subpath = filter(None, subpath.split('/')) + # the traverser *wants* to get routing args from the environ + # as of 0.6.5; the rest of this stuff is for backwards + # compatibility + try: + # 0.6.5 + + routing_args = environ['wsgiorg.routing_args'][1] + except KeyError: + # <= 0.6.4 + routing_args = self.context.__dict__ + try: + view_name = routing_args['view_name'] + except KeyError: + # b/w compat < 0.6.3 + try: + view_name = routing_args['controller'] + except KeyError: + view_name = '' + try: + subpath = routing_args['subpath'] + subpath = filter(None, subpath.split('/')) + except KeyError: + # b/w compat < 0.6.5 + subpath = [] + return self.context, view_name, subpath |
