#NEWLINE# def __finishDeferred( self , val , request ) : #NEWLINE# #INDENT# 'Finishes any Defered/inlineCallback methods. Returns Response' #NEWLINE# if isinstance ( val , Response ) : #NEWLINE# #INDENT# return val #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( val != None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return self . __generateResponse ( request , val ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# msg = ( 'Unexpected server error: %s\n%s' % ( type ( ex ) , ex ) ) #NEWLINE# return self . __createErrorResponse ( request , 500 , msg ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return Response ( 209 , None )