MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __setstate__

Method __setstate__

lib/sqlalchemy/orm/state.py:641–680  ·  view source on GitHub ↗
(self, state_dict: Dict[str, Any])

Source from the content-addressed store, hash-verified

639 return state_dict
640
641 def __setstate__(self, state_dict: Dict[str, Any]) -> None:
642 inst = state_dict["instance"]
643 if inst is not None:
644 self.obj = weakref.ref(inst, self._cleanup)
645 self.class_ = inst.__class__
646 else:
647 self.obj = lambda: None # type: ignore
648 self.class_ = state_dict["class_"]
649
650 self.committed_state = state_dict.get("committed_state", {})
651 self._pending_mutations = state_dict.get("_pending_mutations", {})
652 self.parents = state_dict.get("parents", {})
653 self.modified = state_dict.get("modified", False)
654 self.expired = state_dict.get("expired", False)
655 if "info" in state_dict:
656 self.info.update(state_dict["info"])
657 if "callables" in state_dict:
658 self.callables = state_dict["callables"]
659
660 self.expired_attributes = state_dict["expired_attributes"]
661 else:
662 if "expired_attributes" in state_dict:
663 self.expired_attributes = state_dict["expired_attributes"]
664 else:
665 self.expired_attributes = set()
666
667 self.__dict__.update(
668 [
669 (k, state_dict[k])
670 for k in ("key", "load_options")
671 if k in state_dict
672 ]
673 )
674 if self.key:
675 self.identity_token = self.key[2]
676
677 if "load_path" in state_dict:
678 self.load_path = PathRegistry.deserialize(state_dict["load_path"])
679
680 state_dict["manager"](self, inst, state_dict)
681
682 def _reset(self, dict_: _InstanceDict, key: str) -> None:
683 """Remove the given attribute and any

Callers

nothing calls this directly

Calls 3

deserializeMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected