def set(self, instance, value, **kwargs): _field = instance.Schema().getField('InheritedObjects') uids = [] if value: bc = getToolByName(instance, 'bika_catalog') ids = [x['ObjectID'] for x in value] if ids: proxies = bc(id=ids) if proxies: uids = [x.UID for x in proxies] RecordsField.set(self, instance, value) return _field.set(instance, uids)
def set(self, instance, rules_list, **kwargs): """ Set the reflexrule field. :rules_list: is a list of dictionaries with the following format: [{'actions': [{'act_row_idx': 0, 'action': 'repeat', 'an_result_id': 'rep-1', 'analyst': '', 'otherWS': 'current', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': ''}], 'conditions': [{'analysisservice': '52853cf7d5114b5aa8c159afad2f3da1', 'and_or': 'no', 'cond_row_idx': 0, 'discreteresult': '', 'range0': '11', 'range1': '12'}], 'mother_service_uid': '52853cf7d5114b5aa8c159afad2f3da1', 'rulenumber': '0', 'trigger': 'submit'}, {'actions': [{'act_row_idx': 0, 'action': 'repeat', 'an_result_id': 'rep-2', 'analyst': '', 'otherWS': 'current', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': ''}, {'act_row_idx': 1, 'action': 'repeat', 'an_result_id': 'rep-4', 'analyst': 'analyst1', 'otherWS': 'to_another', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': '70d48adfb34c4231a145f76a858e94cf'}, {'act_row_idx': 2, 'action': 'repeat', 'an_result_id': 'rep-5', 'analyst': '', 'otherWS': 'create_another', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': ''}, {'act_row_idx': 3, 'action': 'repeat', 'an_result_id': 'rep-6', 'analyst': '', 'otherWS': 'no_ws', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': ''}], 'conditions': [{'analysisservice': 'rep-1', 'and_or': 'no', 'cond_row_idx': 0, 'discreteresult': '', 'range0': '12', 'range1': '12'}], 'mother_service_uid': '52853cf7d5114b5aa8c159afad2f3da1', 'rulenumber': '1', 'trigger': 'submit'}, {'actions': [{'act_row_idx': 0, 'action': 'repeat', 'an_result_id': 'rep-3', 'analyst': '', 'otherWS': 'current', 'setresultdiscrete': '', 'setresulton': 'original', 'setresultvalue': '', 'worksheettemplate': ''}], 'conditions': [{'analysisservice': 'rep-1', 'and_or': 'and', 'cond_row_idx': 0, 'discreteresult': '', 'range0': '12', 'range1': '12'}, {'analysisservice': 'rep-2', 'and_or': 'or', 'cond_row_idx': 1, 'discreteresult': '', 'range0': '115', 'range1': '115'}, {'analysisservice': 'rep-1', 'and_or': 'no', 'cond_row_idx': 2, 'discreteresult': '', 'range0': '14', 'range1': '14'}], 'mother_service_uid': '52853cf7d5114b5aa8c159afad2f3da1', 'rulenumber': '2', 'trigger': 'submit'}] This list of dictionaries is how the system will store the reflexrule field info. This dictionaries must be in sync with the browser/widgets/reflexrulewidget.py/process_form() dictionaries format. """ for d in rules_list: # Checking if all dictionary items are correct if not _check_set_values(instance, d): RecordsField.set(self, instance, [], **kwargs) RecordsField.set(self, instance, rules_list, **kwargs)