diff --git a/VERSION b/VERSION index 0dd10107..ad88e09f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.5.1-stable+timestamp.2013.06.20.16.43.32 +Version 2.5.1-stable+timestamp.2013.06.21.01.46.48 diff --git a/gluon/rewrite.py b/gluon/rewrite.py index d5af95c0..baebe8c7 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -244,21 +244,15 @@ def try_rewrite_on_error(http_response, request, environ, ticket=None): url = path_info + '?' + query_string message = 'You are being redirected here' return HTTP(303, message % url, Location=url), environ - else: - error_raising_path = environ['PATH_INFO'] - # Rewrite routes_onerror path. - path_info = '/' + path_info.lstrip( - '/') # add leading '/' if missing - environ['PATH_INFO'] = path_info - error_handling_path = \ - url_in(request, environ)[2]['PATH_INFO'] - # Avoid infinite loop. - if error_handling_path != error_raising_path: - # wsgibase will be called recursively with the routes_onerror path. - environ['PATH_INFO'] = path_info - environ['QUERY_STRING'] = query_string - environ['WEB2PY_STATUS_CODE'] = status - return None, environ + elif not environ.get('__ROUTES_ONERROR__', False): + # wsgibase will be called recursively with + # the routes_onerror path. + environ['__ROUTES_ONERROR__'] = True # limit recursion + path_info = '/' + path_info.lstrip('/') + environ['PATH_INFO'] = path_info + environ['QUERY_STRING'] = query_string + environ['WEB2PY_STATUS_CODE'] = status + return None, environ # do nothing! return http_response, environ