675 self._add_relations(session, rtype, subj_obj_list, inlined) |
675 self._add_relations(session, rtype, subj_obj_list, inlined) |
676 if session.undoable_action('A', rtype): |
676 if session.undoable_action('A', rtype): |
677 for subject, object in subj_obj_list: |
677 for subject, object in subj_obj_list: |
678 self._record_tx_action(session, 'tx_relation_actions', 'A', |
678 self._record_tx_action(session, 'tx_relation_actions', 'A', |
679 eid_from=subject, rtype=rtype, eid_to=object) |
679 eid_from=subject, rtype=rtype, eid_to=object) |
680 |
680 |
681 def _add_relations(self, session, rtype, subj_obj_list, inlined=False): |
681 def _add_relations(self, session, rtype, subj_obj_list, inlined=False): |
682 """add a relation to the source""" |
682 """add a relation to the source""" |
683 sql = [] |
683 sql = [] |
684 if inlined is False: |
684 if inlined is False: |
685 attrs = [{'eid_from': subject, 'eid_to': object} |
685 attrs = [{'eid_from': subject, 'eid_to': object} |
745 if rollback: |
745 if rollback: |
746 try: |
746 try: |
747 session.pool.connection(self.uri).rollback() |
747 session.pool.connection(self.uri).rollback() |
748 if self.repo.config.mode != 'test': |
748 if self.repo.config.mode != 'test': |
749 self.critical('transaction has been rollbacked') |
749 self.critical('transaction has been rollbacked') |
750 except: |
750 except Exception, ex: |
751 pass |
751 pass |
752 if ex.__class__.__name__ == 'IntegrityError': |
752 if ex.__class__.__name__ == 'IntegrityError': |
753 # need string comparison because of various backends |
753 # need string comparison because of various backends |
754 for arg in ex.args: |
754 for arg in ex.args: |
755 mo = re.search('unique_cw_[^ ]+_idx', arg) |
755 mo = re.search('unique_cw_[^ ]+_idx', arg) |
1603 * the table name |
1603 * the table name |
1604 * a tuple of column names |
1604 * a tuple of column names |
1605 * a list of rows (as tuples with one element per column) |
1605 * a list of rows (as tuples with one element per column) |
1606 |
1606 |
1607 Tables are saved in chunks in different files in order to prevent |
1607 Tables are saved in chunks in different files in order to prevent |
1608 a too high memory consumption. |
1608 a too high memory consumption. |
1609 """ |
1609 """ |
1610 def __init__(self, source): |
1610 def __init__(self, source): |
1611 """ |
1611 """ |
1612 :param: source an instance of the system source |
1612 :param: source an instance of the system source |
1613 """ |
1613 """ |