Root registry, defers to mappers so that paths are maintained per-root-mapper.
| 402 | |
| 403 | |
| 404 | class RootRegistry(CreatesToken): |
| 405 | """Root registry, defers to mappers so that |
| 406 | paths are maintained per-root-mapper. |
| 407 | |
| 408 | """ |
| 409 | |
| 410 | __slots__ = () |
| 411 | |
| 412 | inherit_cache = True |
| 413 | |
| 414 | path = natural_path = () |
| 415 | has_entity = False |
| 416 | is_aliased_class = False |
| 417 | is_root = True |
| 418 | is_unnatural = False |
| 419 | |
| 420 | def _getitem( |
| 421 | self, entity: Any |
| 422 | ) -> Union[TokenRegistry, AbstractEntityRegistry]: |
| 423 | if entity in PathToken._intern: |
| 424 | if TYPE_CHECKING: |
| 425 | assert isinstance(entity, _StrPathToken) |
| 426 | return TokenRegistry(self, PathToken._intern[entity]) |
| 427 | else: |
| 428 | try: |
| 429 | return entity._path_registry # type: ignore |
| 430 | except AttributeError: |
| 431 | raise IndexError( |
| 432 | f"invalid argument for RootRegistry.__getitem__: {entity}" |
| 433 | ) |
| 434 | |
| 435 | def _truncate_recursive(self) -> RootRegistry: |
| 436 | return self |
| 437 | |
| 438 | if not TYPE_CHECKING: |
| 439 | __getitem__ = _getitem |
| 440 | |
| 441 | |
| 442 | PathRegistry.root = RootRegistry() |
no outgoing calls