From f8dbdee6167b3b4ab1ee4b2138a3e04e47a7c9df Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 18 Jun 2009 06:35:21 +0000 Subject: - 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. --- repoze/bfg/traversal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'repoze/bfg/traversal.py') 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 -- cgit v1.2.3