'mark processed objects as clean / deleted after a successful
flush().
this method is called within the flush() method after the
execute() method has succeeded and the transaction has been committed.'

def finalize_flush_changes(self):

    states = set(self.states)
    isdel = set((s for (s, (isdelete, listonly)) in self.states.items() if isdelete))
    other = states.difference(isdel)
    self.session._remove_newly_deleted(isdel)
    self.session._register_newly_persistent(other)
