def _saveResultToDB(self, result, resultExts, resultString): #If the result is a string, create empty result and save the string in a result extension with the key resultString if resultString: rslt = models.result() rslt.save() res_ext = models.result_extensions(key='resultString', value=result, result=rslt) res_ext.save() return rslt #Save the result with all of the args rslt = models.result(**result) rslt.save() #If it has extensions, save them all if resultExts: for k, v in resultExts.items(): resExt = models.result_extensions(key=k, value=v, result=rslt) resExt.save() return rslt
def saveResultToDB(self, result, resultExts): # Save the result with all of the args sc = result.pop('score', None) rslt = models.result(content_object=self.model_object, **result) rslt.save() if sc: sc.result = rslt sc.save() #If it has extensions, save them all if resultExts: for k, v in resultExts.items(): resExt = models.extensions(key=k, value=v, content_object=rslt) resExt.save() log_message(self.log_dict, "Result saved to database", __name__, self.saveResultToDB.__name__) return rslt
def saveResultToDB(self, result, resultExts): # Save the result with all of the args sc = result.pop('score', None) rslt = models.result(content_object=self.model_object, **result) rslt.save() if sc: sc.result = rslt sc.save() #If it has extensions, save them all if resultExts: for k, v in resultExts.items(): if not uri.validate_uri(k): err_msg = "Extension ID %s is not a valid URI" % k log_message(self.log_dict, err_msg, __name__, self.saveResultToDB.__name__, True) update_parent_log_status(self.log_dict, 400) raise exceptions.ParamError(err_msg) resExt = models.extensions(key=k, value=v, content_object=rslt) resExt.save() log_message(self.log_dict, "Result saved to database", __name__, self.saveResultToDB.__name__) return rslt