#NEWLINE# @ parse_with ( JsonArg ( 'title' ) , JsonArg ( 'completed' , type = bool ) ) #NEWLINE# def put( self , params , id ) : #NEWLINE# #INDENT# todo = models . Todo . query . get ( id ) #NEWLINE# if ( todo is None ) : #NEWLINE# #INDENT# todo = models . Todo ( id = id ) #NEWLINE# #UNINDENT# for ( key , value ) in params . iteritems ( ) : #NEWLINE# #INDENT# setattr ( todo , key , value ) #NEWLINE# #UNINDENT# models . db . session . add ( todo ) #NEWLINE# try : #NEWLINE# #INDENT# models . db . session . commit ( ) #NEWLINE# #UNINDENT# except IntegrityError : #NEWLINE# #INDENT# abort ( CONFLICT ) #NEWLINE# #UNINDENT# return todo