From d5324f87e0c3500b4cf30fca78d05873bbda7022 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Mon, 6 May 2013 15:07:47 -0700 Subject: [PATCH] error_mapper: Don't redirect to ErrorController for pagecached errors. This prevents a situation where we get a cached error (e.g. a 404) back from the pagecache and then the error_mapper (called by the ErrorDocuments middleware) sees that status code and redirects the app to the ErrorController which then re-renders the error and inserts it into the pagecache at the end of the request. --- r2/r2/config/middleware.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/r2/r2/config/middleware.py b/r2/r2/config/middleware.py index 96f16338a..281339a10 100644 --- a/r2/r2/config/middleware.py +++ b/r2/r2/config/middleware.py @@ -57,12 +57,15 @@ webob.util.status_reasons[429] = HTTPTooManyRequests.title #from pylons.middleware import error_mapper def error_mapper(code, message, environ, global_conf=None, **kw): - from pylons import c if environ.get('pylons.error_call'): return None else: environ['pylons.error_call'] = True + from pylons import c + if c.used_cache: + return + if global_conf is None: global_conf = {} codes = [304, 400, 401, 403, 404, 409, 415, 429, 503]