| 2423 | ) |
| 2424 | |
| 2425 | def _is_orphan(self, state: InstanceState[_O]) -> bool: |
| 2426 | orphan_possible = False |
| 2427 | for mapper in self.iterate_to_root(): |
| 2428 | for key, cls in mapper._delete_orphans: |
| 2429 | orphan_possible = True |
| 2430 | |
| 2431 | has_parent = attributes.manager_of_class(cls).has_parent( |
| 2432 | state, key, optimistic=state.has_identity |
| 2433 | ) |
| 2434 | |
| 2435 | if self.legacy_is_orphan and has_parent: |
| 2436 | return False |
| 2437 | elif not self.legacy_is_orphan and not has_parent: |
| 2438 | return True |
| 2439 | |
| 2440 | if self.legacy_is_orphan: |
| 2441 | return orphan_possible |
| 2442 | else: |
| 2443 | return False |
| 2444 | |
| 2445 | def has_property(self, key: str) -> bool: |
| 2446 | return key in self._props |