| 724 | return _set_callable |
| 725 | |
| 726 | def _expire( |
| 727 | self, dict_: _InstanceDict, modified_set: Set[InstanceState[Any]] |
| 728 | ) -> None: |
| 729 | self.expired = True |
| 730 | if self.modified: |
| 731 | modified_set.discard(self) |
| 732 | self.committed_state.clear() |
| 733 | self.modified = False |
| 734 | |
| 735 | self._strong_obj = None |
| 736 | |
| 737 | if "_pending_mutations" in self.__dict__: |
| 738 | del self.__dict__["_pending_mutations"] |
| 739 | |
| 740 | if "parents" in self.__dict__: |
| 741 | del self.__dict__["parents"] |
| 742 | |
| 743 | self.expired_attributes.update( |
| 744 | [impl.key for impl in self.manager._loader_impls] |
| 745 | ) |
| 746 | |
| 747 | if self.callables: |
| 748 | # the per state loader callables we can remove here are |
| 749 | # LoadDeferredColumns, which undefers a column at the instance |
| 750 | # level that is mapped with deferred, and LoadLazyAttribute, |
| 751 | # which lazy loads a relationship at the instance level that |
| 752 | # is mapped with "noload" or perhaps "immediateload". |
| 753 | # Before 1.4, only column-based |
| 754 | # attributes could be considered to be "expired", so here they |
| 755 | # were the only ones "unexpired", which means to make them deferred |
| 756 | # again. For the moment, as of 1.4 we also apply the same |
| 757 | # treatment relationships now, that is, an instance level lazy |
| 758 | # loader is reset in the same way as a column loader. |
| 759 | for k in self.expired_attributes.intersection(self.callables): |
| 760 | del self.callables[k] |
| 761 | |
| 762 | for k in self.manager._collection_impl_keys.intersection(dict_): |
| 763 | collection = dict_.pop(k) |
| 764 | collection._sa_adapter.invalidated = True |
| 765 | |
| 766 | if self._last_known_values: |
| 767 | self._last_known_values.update( |
| 768 | {k: dict_[k] for k in self._last_known_values if k in dict_} |
| 769 | ) |
| 770 | |
| 771 | for key in self.manager._all_key_set.intersection(dict_): |
| 772 | del dict_[key] |
| 773 | |
| 774 | self.manager.dispatch.expire(self, None) |
| 775 | |
| 776 | def _expire_attributes( |
| 777 | self, |