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.
This commit is contained in:
Neil Williams
2013-05-06 15:07:47 -07:00
parent aa0739b428
commit d5324f87e0

View File

@@ -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]