#NEWLINE# @ exception . wrap_pecan_controller_exception #NEWLINE# @ pecan . expose ( 'json' , content_type = 'application/json-patch+json' ) #NEWLINE# def patch( self , uuid ) : #NEWLINE# #INDENT# 'Patch an existing CAMP-style plan.' #NEWLINE# handler = plan_handler . PlanHandler ( pecan . request . security_context ) #NEWLINE# plan_obj = handler . get ( uuid ) #NEWLINE# if ( ( not pecan . request . body ) or ( len ( pecan . request . body ) < 1 ) ) : #NEWLINE# #INDENT# raise exception . BadRequest ( reason = 'empty request body' ) #NEWLINE# #UNINDENT# if ( ( pecan . request . content_type is None ) or ( pecan . request . content_type != 'application/json-patch+json' ) ) : #NEWLINE# #INDENT# raise exception . UnsupportedMediaType ( name = pecan . request . content_type , method = 'PATCH' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# patch = jsonpatch . JsonPatch . from_string ( pecan . request . body ) #NEWLINE# patched_obj = patch . apply ( plan_obj . refined_content ( ) ) #NEWLINE# db_obj = handler . update ( uuid , patched_obj ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise exception . BadRequest ( reason = MAL_PATCH_ERR ) #NEWLINE# #UNINDENT# except jsonpatch . JsonPatchConflict : #NEWLINE# #INDENT# raise exception . Unprocessable #NEWLINE# #UNINDENT# except jsonpatch . JsonPatchException as jpe : #NEWLINE# #INDENT# raise JsonPatchProcessingException ( reason = six . text_type ( db_obj ) ) #NEWLINE# #UNINDENT# return fluff_plan ( db_obj . refined_content ( ) , db_obj . uuid )