From 6ecdbc409d2109a9e7fc5367c64067f0400f07cc Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 22 Jun 2009 00:12:45 +0000 Subject: - Adding ``*path_info`` to a route no longer changes the PATH_INFO for a request that matches using URL dispatch. This feature was only there to service the ``repoze.bfg.wsgi.wsgiapp2`` decorator and it did it wrong; use ``*subpath`` instead now. - The interface generation performed for named request factories had the wrong base classes. --- repoze/bfg/wsgi.py | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) (limited to 'repoze/bfg/wsgi.py') diff --git a/repoze/bfg/wsgi.py b/repoze/bfg/wsgi.py index c7853c035..3991d3344 100644 --- a/repoze/bfg/wsgi.py +++ b/repoze/bfg/wsgi.py @@ -71,32 +71,21 @@ def wsgiapp2(wrapped): """ def decorator(context, request): traversed = request.traversed - if traversed is not None: - # We need to fix up PATH_INFO and SCRIPT_NAME to give the - # subapplication the right information, sans the info it - # took to traverse here. If ``traversed`` is None here, - # it means that no traversal was done. For example, it - # will be None in the case that the context is one - # obtained via a Routes match (Routes 'traversal' doesn't - # actually traverse). If this view is invoked on a Routes - # context, this fixup is not invoked. Instead, the route - # used to reach it should use *path_info in the actual - # route pattern to get a similar fix-up done. - vroot_path = request.virtual_root_path or [] - view_name = request.view_name - subpath = request.subpath or [] - script_list = traversed[len(vroot_path):] - script_list = [ quote_path_segment(name) for name in script_list ] - if view_name: - script_list.append(quote_path_segment(view_name)) - script_name = '/' + '/'.join(script_list) - path_list = [ quote_path_segment(name) for name in subpath ] - path_info = '/' + '/'.join(path_list) - request.environ['PATH_INFO'] = path_info - script_name = request.environ['SCRIPT_NAME'] + script_name - if script_name.endswith('/'): - script_name = script_name[:-1] - request.environ['SCRIPT_NAME'] = script_name + vroot_path = request.virtual_root_path or [] + view_name = request.view_name + subpath = request.subpath or () + script_list = traversed[len(vroot_path):] + script_list = [ quote_path_segment(name) for name in script_list ] + if view_name: + script_list.append(quote_path_segment(view_name)) + script_name = '/' + '/'.join(script_list) + path_list = [ quote_path_segment(name) for name in subpath ] + path_info = '/' + '/'.join(path_list) + request.environ['PATH_INFO'] = path_info + script_name = request.environ['SCRIPT_NAME'] + script_name + if script_name.endswith('/'): + script_name = script_name[:-1] + request.environ['SCRIPT_NAME'] = script_name return request.get_response(wrapped) return wraps(wrapped)(decorator) # grokkability -- cgit v1.2.3