Ejemplo n.º 1
0
 def _resolve_diff(self, inst, prev, curr):
     added, deleted = diff_unsorted(prev, curr) #@UnusedVariable
     for obj in added:
         if not self._find_existing_primary(inst, obj):
             new_primary = self.PrimaryTable()
             setattr(new_primary, self.owner_fk, inst)
             setattr(new_primary, self.foreign_fk, obj)
             inst.add(new_primary)
     if inst.session is not None:
         for obj in deleted:
             to_delete = self._find_existing_primary(inst, obj)
             if to_delete:
                 to_delete.delete()
Ejemplo n.º 2
0
 def test_diff_unsorted(self):
     """Test the diff_unsorted() method"""
     added, deleted = util.diff_unsorted(['a', 'b', 'c'], ['a', 'b', 'd'])
     self.assertEqual(added, ['d'])
     self.assertEqual(deleted, ['c'])
Ejemplo n.º 3
0
 def _resolve_diff(self, inst, prev, curr):
     added, deleted = diff_unsorted(prev, curr) #@UnusedVariable
     for obj in added:
         setattr(obj, self.backref, inst)
     for obj in deleted:
         setattr(obj, self.backref, None)
Ejemplo n.º 4
0
 def _resolve_diff(self, inst, prev, curr):
     added, deleted = diff_unsorted(prev, curr) #@UnusedVariable
     for obj in deleted:
         self.foreign_field._set(obj, None, None)
     for i, obj in enumerate(curr, start=1):
         self.foreign_field._set(obj, inst, i)