Return an iterator of (state, state.dict, mapper, connection). The states are sorted according to _sort_states, then paired with the connection they should be using for the given unit of work transaction.
(base_mapper, uowtransaction, states)
| 1745 | |
| 1746 | |
| 1747 | def _connections_for_states(base_mapper, uowtransaction, states): |
| 1748 | """Return an iterator of (state, state.dict, mapper, connection). |
| 1749 | |
| 1750 | The states are sorted according to _sort_states, then paired |
| 1751 | with the connection they should be using for the given |
| 1752 | unit of work transaction. |
| 1753 | |
| 1754 | """ |
| 1755 | # if session has a connection callable, |
| 1756 | # organize individual states with the connection |
| 1757 | # to use for update |
| 1758 | if uowtransaction.session.connection_callable: |
| 1759 | connection_callable = uowtransaction.session.connection_callable |
| 1760 | else: |
| 1761 | connection = uowtransaction.transaction.connection(base_mapper) |
| 1762 | connection_callable = None |
| 1763 | |
| 1764 | for state in _sort_states(base_mapper, states): |
| 1765 | if connection_callable: |
| 1766 | connection = connection_callable(base_mapper, state.obj()) |
| 1767 | |
| 1768 | mapper = state.manager.mapper |
| 1769 | |
| 1770 | yield state, state.dict, mapper, connection |
| 1771 | |
| 1772 | |
| 1773 | def _sort_states(mapper, states): |
no test coverage detected