Commit attributes. This is used by a partial-attribute load operation to mark committed those attributes which were refreshed from the database. Attributes marked as "expired" can potentially remain "expired" after this step if a value was not populated in state.dic
(self, dict_: _InstanceDict, keys: Iterable[str])
| 965 | ) |
| 966 | |
| 967 | def _commit(self, dict_: _InstanceDict, keys: Iterable[str]) -> None: |
| 968 | """Commit attributes. |
| 969 | |
| 970 | This is used by a partial-attribute load operation to mark committed |
| 971 | those attributes which were refreshed from the database. |
| 972 | |
| 973 | Attributes marked as "expired" can potentially remain "expired" after |
| 974 | this step if a value was not populated in state.dict. |
| 975 | |
| 976 | """ |
| 977 | for key in keys: |
| 978 | self.committed_state.pop(key, None) |
| 979 | |
| 980 | self.expired = False |
| 981 | |
| 982 | self.expired_attributes.difference_update( |
| 983 | set(keys).intersection(dict_) |
| 984 | ) |
| 985 | |
| 986 | # the per-keys commit removes object-level callables, |
| 987 | # while that of commit_all does not. it's not clear |
| 988 | # if this behavior has a clear rationale, however tests do |
| 989 | # ensure this is what it does. |
| 990 | if self.callables: |
| 991 | for key in ( |
| 992 | set(self.callables).intersection(keys).intersection(dict_) |
| 993 | ): |
| 994 | del self.callables[key] |
| 995 | |
| 996 | def _commit_all( |
| 997 | self, |