#NEWLINE# def register( self , cls_list ) : #NEWLINE# #INDENT# 'Register a class to be given a REST API.' #NEWLINE# for cls in cls_list : #NEWLINE# #INDENT# serializable_model = type ( ( cls . __name__ + 'Serializable' ) , ( cls , SerializableModel ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# service = ( ReadService if self . readonly else WriteService ) #NEWLINE# new_endpoint = type ( ( cls . __name__ + 'Endpoint' ) , ( service , ) , { #NEWLINE# #INDENT# '__model__' : serializable_model , #NEWLINE# '__db__' : self . db , #NEWLINE# #UNINDENT# } ) #NEWLINE# view_func = new_endpoint . as_view ( new_endpoint . __model__ . __tablename__ ) #NEWLINE# self . blueprint . add_url_rule ( ( '/' + new_endpoint . __model__ . __tablename__ ) , defaults = { #NEWLINE# #INDENT# 'resource_id' : None , #NEWLINE# #UNINDENT# } , view_func = view_func ) #NEWLINE# self . blueprint . add_url_rule ( '/{resource}/<resource_id>' . format ( resource = new_endpoint . __model__ . __tablename__ ) , view_func = view_func )