From 7664aaa6cce7b6f559e896d4de7c5f283b1d2a50 Mon Sep 17 00:00:00 2001 From: ianb Date: Fri, 20 Jan 2006 06:02:01 +0000 Subject: Fix a problem with errors during the response iterator, and missing method --- paste/evalexception/middleware.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'paste/evalexception') diff --git a/paste/evalexception/middleware.py b/paste/evalexception/middleware.py index 83dc37b..1ad6df6 100644 --- a/paste/evalexception/middleware.py +++ b/paste/evalexception/middleware.py @@ -233,7 +233,12 @@ class EvalException(object): try: __traceback_supplement__ = errormiddleware.Supplement, self, environ app_iter = self.application(environ, detect_start_response) - return self.catching_iter(app_iter, environ) + try: + return_iter = list(app_iter) + return return_iter + finally: + if hasattr(app_iter, 'close'): + app_iter.close() except: exc_info = sys.exc_info() for expected in environ.get('paste.expected_exceptions', []): @@ -294,6 +299,18 @@ class EvalException(object): % close_response) yield response + def exception_handler(self, exc_info, environ): + simple_html_error = False + if self.xmlhttp_key: + get_vars = wsgilib.parse_querystring(environ) + if dict(get_vars).get(self.xmlhttp_key): + simple_html_error = True + return errormiddleware.handle_exception( + exc_info, environ['wsgi.errors'], + html=True, + debug_mode=True, + simple_html_error=simple_html_error) + def eval_javascript(self, base_path, counter): base_path += '/_debug' return ( -- cgit v1.2.1