Skip to content

Commit

Permalink
reset path_info and script_name after request processing is over
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Jul 26, 2016
1 parent d027212 commit b360596
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,10 @@
unreleased
----------

- Fix another regression where the toolbar was modifying requests to the
toolbar itself such that the ``script_name`` and ``path_info`` were
different after handling the request than before.

3.0.2 (2016-07-02)
------------------

Expand Down
12 changes: 9 additions & 3 deletions pyramid_debugtoolbar/toolbar.py
Expand Up @@ -190,9 +190,15 @@ def toolbar_tween(request):
if p.startswith(root_path):
# we know root_path will always have a trailing slash
# but script_name doesn't want it
request.script_name += root_path[:-1]
request.path_info = request.path_info[len(root_path) - 1:]
return dispatch(request)
try:
old_script_name = request.script_name
old_path_info = request.path_info
request.script_name += root_path[:-1]
request.path_info = request.path_info[len(root_path) - 1:]
return dispatch(request)
finally:
request.script_name = old_script_name
request.path_info = old_path_info

request.exc_history = exc_history
request.history = request_history
Expand Down

0 comments on commit b360596

Please sign in to comment.