From 2d9df0c6e85a20f434778510d10c7fb4c8eb5265 Mon Sep 17 00:00:00 2001 From: ianb Date: Sat, 14 May 2005 22:40:47 +0000 Subject: Added start_response exc_info argument --- paste/cgitb_catcher.py | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) (limited to 'paste/cgitb_catcher.py') diff --git a/paste/cgitb_catcher.py b/paste/cgitb_catcher.py index b8f4915..732f7e1 100644 --- a/paste/cgitb_catcher.py +++ b/paste/cgitb_catcher.py @@ -19,8 +19,8 @@ def middleware(application, **kw): def start_application(environ, start_response): started = [] - def detect_start_response(status, headers): - started.append(start_response(status, headers)) + def detect_start_response(status, headers, exc_info=None): + started.append(start_response(status, headers, exc_info)) return started[0] try: @@ -55,41 +55,3 @@ def middleware(application, **kw): yield dummy_file.getvalue() return start_application - -def simple_middleware(application, **kw): - - def start_application(environ, start_response): - started = [] - - def detect_start_response(status, headers): - started.append(start_response(status, headers)) - return started[0] - - try: - app_iter = application(environ, start_response) - return catching_iter(app_iter) - except: - if not started: - write = start_response('500 Internal Server Error', - [('content-type', 'text/html')]) - else: - write = started[0] - - out = String() - traceback.print_exc(file=out) - return ['
%s
' - % out.getvalue()] - - def catching_iter(iter): - if not iter: - raise StopIteration - try: - for v in iter: - yield iter - except: - exc = sys.exc_info() - dummy_file = StringIO() - traceback.print_exc(file=dummy_file) - yield dummy_file.getvalue() - - return start_application -- cgit v1.2.1