#NEWLINE# def call_app( self , req , app = None , expect_exception = False ) : #NEWLINE# #INDENT# if ( app is None ) : #NEWLINE# #INDENT# app = self . app #NEWLINE# #UNINDENT# self . authorized = [ ] #NEWLINE# def authorize( req ) : #NEWLINE# #INDENT# self . authorized . append ( req ) #NEWLINE# #UNINDENT# if ( 'swift.authorize' not in req . environ ) : #NEWLINE# #INDENT# req . environ [ 'swift.authorize' ] = authorize #NEWLINE# #UNINDENT# req . headers . setdefault ( 'User-Agent' , 'Marula Kruger' ) #NEWLINE# status = [ None ] #NEWLINE# headers = [ None ] #NEWLINE# def start_response( s , h , ei = None ) : #NEWLINE# #INDENT# status [ 0 ] = s #NEWLINE# headers [ 0 ] = h #NEWLINE# #UNINDENT# body_iter = app ( req . environ , start_response ) #NEWLINE# body = '' #NEWLINE# caught_exc = None #NEWLINE# try : #NEWLINE# #INDENT# for chunk in body_iter : #NEWLINE# #INDENT# body += chunk #NEWLINE# #UNINDENT# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# if expect_exception : #NEWLINE# #INDENT# caught_exc = exc #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# if expect_exception : #NEWLINE# #INDENT# return ( status [ 0 ] , headers [ 0 ] , body , caught_exc ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( status [ 0 ] , headers [ 0 ] , body )