diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-18 06:35:21 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-18 06:35:21 +0000 |
| commit | f8dbdee6167b3b4ab1ee4b2138a3e04e47a7c9df (patch) | |
| tree | 2c03802fe9b3ab56d8e8bd067e437d3f29b92006 /repoze/bfg/traversal.py | |
| parent | 95a9cfc326f0fcb3bdfce1efe5c25748a7f8f077 (diff) | |
| download | pyramid-f8dbdee6167b3b4ab1ee4b2138a3e04e47a7c9df.tar.gz pyramid-f8dbdee6167b3b4ab1ee4b2138a3e04e47a7c9df.tar.bz2 pyramid-f8dbdee6167b3b4ab1ee4b2138a3e04e47a7c9df.zip | |
- The matchdict related to the matching of a Routes route is available
on the request as the ``matchdict`` attribute:
``request.matchdict``. If no route matched, this attribute will be
None.
Diffstat (limited to 'repoze/bfg/traversal.py')
| -rw-r--r-- | repoze/bfg/traversal.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/repoze/bfg/traversal.py b/repoze/bfg/traversal.py index 40f65901f..63fd71e74 100644 --- a/repoze/bfg/traversal.py +++ b/repoze/bfg/traversal.py @@ -493,6 +493,7 @@ class ModelGraphTraverser(object): self.root = root def __call__(self, environ, _marker=_marker): + matchdict = None if 'bfg.routes.matchdict' in environ: # this request matched a Routes route matchdict = environ['bfg.routes.matchdict'] @@ -541,19 +542,22 @@ class ModelGraphTraverser(object): if segment[:2] =='@@': return dict(context=ob, view_name=segment[2:], subpath=path[i:], traversed=traversed, virtual_root=vroot, - virtual_root_path=vroot_path, root=self.root) + virtual_root_path=vroot_path, root=self.root, + matchdict=matchdict) try: getitem = ob.__getitem__ except AttributeError: return dict(context=ob, view_name=segment, subpath=path[i:], traversed=traversed, virtual_root=vroot, - virtual_root_path=vroot_path, root=self.root) + virtual_root_path=vroot_path, root=self.root, + matchdict=matchdict) try: next = getitem(segment) except KeyError: return dict(context=ob, view_name=segment, subpath=path[i:], traversed=traversed, virtual_root=vroot, - virtual_root_path=vroot_path, root=self.root) + virtual_root_path=vroot_path, root=self.root, + matchdict=matchdict) if vroot_idx == i-1: vroot = ob traversed.append(segment) @@ -563,7 +567,7 @@ class ModelGraphTraverser(object): return dict(context=ob, view_name=u'', subpath=subpath, traversed=traversed, virtual_root=vroot, virtual_root_path=vroot_path, - root=self.root) + root=self.root, matchdict=matchdict) class TraversalContextURL(object): """ The IContextURL adapter used to generate URLs for a context |
