Listen for set/replace events on the target data member. Establish a weak reference to the parent object on the incoming value, remove it for the one outgoing.
(
target: InstanceState[_O],
value: MutableBase | None,
oldvalue: MutableBase | None,
initiator: AttributeEventToken,
)
| 535 | load(state) |
| 536 | |
| 537 | def set_( |
| 538 | target: InstanceState[_O], |
| 539 | value: MutableBase | None, |
| 540 | oldvalue: MutableBase | None, |
| 541 | initiator: AttributeEventToken, |
| 542 | ) -> MutableBase | None: |
| 543 | class="st">"""Listen for set/replace events on the target |
| 544 | data member. |
| 545 | |
| 546 | Establish a weak reference to the parent object |
| 547 | on the incoming value, remove it for the one |
| 548 | outgoing. |
| 549 | |
| 550 | class="st">""" |
| 551 | if value is oldvalue: |
| 552 | return value |
| 553 | |
| 554 | if not isinstance(value, cls): |
| 555 | value = cls.coerce(key, value) |
| 556 | if value is not None: |
| 557 | value._parents[target] = key |
| 558 | if isinstance(oldvalue, cls): |
| 559 | oldvalue._parents.pop(inspect(target), None) |
| 560 | return value |
| 561 | |
| 562 | def pickle( |
| 563 | state: InstanceState[_O], state_dict: Dict[str, Any] |