#NEWLINE# def get_object_or_404( self , obj , * args , **kwargs ) : #NEWLINE# #INDENT# 'Get object instance by ID\n\n        :http: 404 when not found\n        :returns: object instance\n        ' #NEWLINE# log_404 = kwargs . pop ( 'log_404' , None ) #NEWLINE# log_get = kwargs . pop ( 'log_get' , None ) #NEWLINE# uid = kwargs . get ( 'id' , ( args [ 0 ] if args else None ) ) #NEWLINE# if ( uid is None ) : #NEWLINE# #INDENT# if log_404 : #NEWLINE# #INDENT# getattr ( logger , log_404 [ 0 ] ) ( log_404 [ 1 ] ) #NEWLINE# #UNINDENT# raise self . http ( 404 , 'Invalid ID specified' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# instance = obj . get_by_uid ( uid ) #NEWLINE# if ( not instance ) : #NEWLINE# #INDENT# raise self . http ( 404 , '{0} not found' . format ( obj . __name__ ) ) #NEWLINE# #UNINDENT# if log_get : #NEWLINE# #INDENT# getattr ( logger , log_get [ 0 ] ) ( log_get [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# return instance