#NEWLINE# def get_resource( self , transaction ) : #NEWLINE# #INDENT# '\n        Render a GET request.\n\n        :param transaction: the transaction\n        :return: the transaction\n        ' #NEWLINE# method = getattr ( transaction . resource , 'render_GET' , None ) #NEWLINE# transaction . resource . actual_content_type = None #NEWLINE# if ( transaction . request . accept is not None ) : #NEWLINE# #INDENT# transaction . resource . actual_content_type = transaction . request . accept #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# resource = method ( request = transaction . request ) #NEWLINE# #UNINDENT# except NotImplementedError : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . METHOD_NOT_ALLOWED . number #NEWLINE# return transaction #NEWLINE# #UNINDENT# if isinstance ( resource , Resource ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( resource , tuple ) and ( len ( resource ) == 2 ) ) : #NEWLINE# #INDENT# ( resource , callback ) = resource #NEWLINE# resource = self . _handle_separate ( transaction , callback ) #NEWLINE# if ( not isinstance ( resource , Resource ) ) : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . INTERNAL_SERVER_ERROR . number #NEWLINE# return transaction #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . INTERNAL_SERVER_ERROR . number #NEWLINE# return transaction . response #NEWLINE# #UNINDENT# #UNINDENT# if ( resource . etag in transaction . request . etag ) : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . VALID . number #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . CONTENT . number #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# transaction . response . payload = resource . payload #NEWLINE# if ( ( resource . actual_content_type is not None ) and ( resource . actual_content_type != defines . Content_types [ 'text/plain' ] ) ) : #NEWLINE# #INDENT# transaction . response . content_type = resource . actual_content_type #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# transaction . response . code = defines . Codes . NOT_ACCEPTABLE . number #NEWLINE# return transaction . response #NEWLINE# #UNINDENT# assert isinstance ( resource , Resource ) #NEWLINE# if ( resource . etag is not None ) : #NEWLINE# #INDENT# transaction . response . etag = resource . etag #NEWLINE# #UNINDENT# if ( resource . max_age is not None ) : #NEWLINE# #INDENT# transaction . response . max_age = resource . max_age #NEWLINE# #UNINDENT# transaction . resource = resource #NEWLINE# return transaction