#NEWLINE# @ requires_auth ( ) #NEWLINE# def list( object_type ) : #NEWLINE# #INDENT# s_obj = singularize ( object_type ) #NEWLINE# api = api_from_models ( ) #NEWLINE# if ( flask . request . method == 'POST' ) : #NEWLINE# #INDENT# data = flask . request . json #NEWLINE# try : #NEWLINE# #INDENT# model_object = api . _model_create ( object_type , data ) #NEWLINE# #UNINDENT# except KeyError as e : #NEWLINE# #INDENT# return http_badrequest ( msg = str ( e ) ) #NEWLINE# #UNINDENT# _notify ( model_object , object_type , model_object [ 'id' ] ) #NEWLINE# href = ( flask . request . base_url + str ( model_object [ 'id' ] ) ) #NEWLINE# return http_response ( 201 , ( '%s Created' % s_obj . capitalize ( ) ) , ref = href , ** { #NEWLINE# #INDENT# s_obj : model_object , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( flask . request . method == 'GET' ) : #NEWLINE# #INDENT# model_objects = api . _model_get_all ( object_type ) #NEWLINE# return http_response ( 200 , 'success' , ** { #NEWLINE# #INDENT# object_type : model_objects , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return http_notfound ( msg = ( 'Unknown method %s' % flask . request . method ) )