#NEWLINE# def update( self , request , * args , **kwargs ) : #NEWLINE# #INDENT# if ( ( not self . has_model ( ) ) or ( not self . has_form ( ) ) ) : #NEWLINE# #INDENT# return rc . NOT_IMPLEMENTED #NEWLINE# #UNINDENT# pkfield = ( kwargs . get ( self . model . _meta . pk . name ) or request . data . get ( self . model . _meta . pk . name ) ) #NEWLINE# if ( ( not pkfield ) or ( request . data is None ) ) : #NEWLINE# #INDENT# return rc . BAD_REQUEST #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# obj = self . model . objects . get ( pk = pkfield ) #NEWLINE# #UNINDENT# except ObjectDoesNotExist : #NEWLINE# #INDENT# return rc . NOT_FOUND #NEWLINE# #UNINDENT# if ( not self . check_instance_permission ( request , obj , 'w' ) ) : #NEWLINE# #INDENT# return rc . FORBIDDEN #NEWLINE# #UNINDENT# attrs = self . flatten_dict ( request ) #NEWLINE# form = self . form ( instance = obj , ** attrs ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# obj = form . save ( ) #NEWLINE# return obj #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . status = 400 #NEWLINE# return form . errors