def apply_submitted_edits(response): """ Apply edits submitted as a diffs object via web, i.e member of response obj """ try: inv.log_transac.info( str(response.referrer) + ' : ' + str(response.data)) except Exception as e: #If we can't log the attempt, we can still maybe log the failure. Perhaps data is missing etc inv.log_transac.error("Failed to log transaction " + str(e)) #Validate the response and if good pass to the DB interface code try: decoder = json.JSONDecoder() resp_str = decoder.decode(response.data) except Exception as e: inv.log_dest.error("Error decoding edits " + str(e)) raise DiffDecodeError(str(e)) try: validate_edits(resp_str) #This throws custom exceptions resp_str = process_edits(resp_str) update_fields(resp_str) except Exception as e: inv.log_dest.error("Error in edit validation " + str(e)) raise e
def apply_submitted_edits(response): """ Attempt to apply edits submitted as a diffs object via web, i.e member of response obj """ try: inv.log_transac.info(str(response.referrer)+' : '+str(response.data)) except Exception as e: #If we can't log the attempt, we can still maybe log the failure. Perhaps data is missing etc inv.log_transac.error("Failed to log transaction "+str(e)) #Validate the response and if good pass to the DB interface code try: decoder = json.JSONDecoder() resp_str = decoder.decode(response.data) except Exception as e: inv.log_dest.error("Error decoding edits "+str(e)) raise DiffDecodeError(str(e)) try: check_locks(resp_str) # Throws custom error if locked validate_edits(resp_str) #This throws custom exceptions resp_str = process_edits(resp_str) update_fields(resp_str) except Exception as e: #Log and re-raise inv.log_dest.error("Error in edit validation "+str(e)) raise e
def apply_edits(diff): """ Apply edits as a diff Use for applying edits from exports etc. Copy is explicitly made Note there is also apply_rollback for rollbacks """ diff_to_apply = deepcopy(diff) try: validate_edits(diff_to_apply) #This throws custom exceptions diff_to_apply = process_edits(diff_to_apply) update_fields(diff_to_apply) except Exception as e: raise e
def apply_edits(diff): """ Apply edits as a diff Use for applying edits from exports etc. Copy is explicitly made Note there is also apply_rollback for rollbacks """ diff_to_apply = deepcopy(diff) try: validate_edits(diff_to_apply) #This throws custom exceptions diff_to_apply = process_edits(diff_to_apply) update_fields(diff_to_apply) except Exception as e: inv.log_dest.error("Error in edit validation or apply "+str(e)) raise e
def apply_submitted_edits(response): """ Attempt to apply edits submitted as a diffs object via web, i.e member of response obj """ #Validate the response and if good pass to the DB interface code try: decoder = json.JSONDecoder() resp_str = decoder.decode(response.data) except Exception as e: raise DiffDecodeError(str(e)) try: # check_locks(resp_str) # Throws custom error if locked validate_edits(resp_str) #This throws custom exceptions resp_str = process_edits(resp_str) update_fields(resp_str) except Exception as e: #Log and re-raise # inv.log_dest.error("Error in edit validation "+str(e)) raise e