From 2f5bbe61d249b3c8884072d33047ad7522dd8068 Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Thu, 2 Sep 2010 02:40:17 -0500 Subject: Always return something from start_response, even if we don't plan to actually use the written response (because it will be forwarded). Might fix: http://trac.pythonpaste.org/pythonpaste/ticket/166 --- paste/errordocument.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'paste/errordocument.py') diff --git a/paste/errordocument.py b/paste/errordocument.py index d3d35bb..e57c162 100644 --- a/paste/errordocument.py +++ b/paste/errordocument.py @@ -10,6 +10,7 @@ URL where the content can be displayed to the user as an error document. """ import warnings +import sys from urlparse import urlparse from paste.recursive import ForwardRequestException, RecursiveMiddleware, RecursionLoop from paste.util import converters @@ -85,7 +86,7 @@ class StatusKeeper(object): return self.app(environ, keep_status_start_response) except RecursionLoop, e: environ['wsgi.errors'].write('Recursion error getting error page: %s\n' % e) - keep_status_start_response('500 Server Error', [('Content-type', 'text/plain')]) + keep_status_start_response('500 Server Error', [('Content-type', 'text/plain')], sys.exc_info()) return ['Error: %s. (Error page could not be fetched)' % self.status] @@ -160,6 +161,7 @@ class StatusBasedForward(object): def __call__(self, environ, start_response): url = [] + writer = [] def change_response(status, headers, exc_info=None): status_code = status.split(' ') @@ -182,10 +184,12 @@ class StatusBasedForward(object): raise TypeError( 'Expected the url to internally ' 'redirect to in the StatusBasedForward mapper' - 'to be a string or None, not %s'%repr(new_url) - ) + 'to be a string or None, not %r' % new_url) if new_url: url.append([new_url, status, headers]) + # We have to allow the app to write stuff, even though + # we'll ignore it: + return [].append else: return start_response(status, headers, exc_info) -- cgit v1.2.1