Root registry, defers to mappers so that paths are maintained per-root-mapper.
| 368 | |
| 369 | |
| 370 | class RootRegistry(_CreatesToken): |
| 371 | """Root registry, defers to mappers so that |
| 372 | paths are maintained per-root-mapper. |
| 373 | |
| 374 | """ |
| 375 | |
| 376 | __slots__ = () |
| 377 | |
| 378 | inherit_cache = True |
| 379 | |
| 380 | path = natural_path = () |
| 381 | has_entity = False |
| 382 | is_aliased_class = False |
| 383 | is_root = True |
| 384 | is_unnatural = False |
| 385 | |
| 386 | def _getitem( |
| 387 | self, entity: Any |
| 388 | ) -> Union[_TokenRegistry, _AbstractEntityRegistry]: |
| 389 | if entity in PathToken._intern: |
| 390 | if TYPE_CHECKING: |
| 391 | assert isinstance(entity, _StrPathToken) |
| 392 | return _TokenRegistry(self, PathToken._intern[entity]) |
| 393 | else: |
| 394 | try: |
| 395 | return entity._path_registry # type: ignore |
| 396 | except AttributeError: |
| 397 | raise IndexError( |
| 398 | f"invalid argument for RootRegistry.__getitem__: {entity}" |
| 399 | ) |
| 400 | |
| 401 | def _truncate_recursive(self) -> RootRegistry: |
| 402 | return self |
| 403 | |
| 404 | if not TYPE_CHECKING: |
| 405 | __getitem__ = _getitem |
| 406 | |
| 407 | |
| 408 | PathRegistry.root = RootRegistry() |
no outgoing calls