MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / register_class

Function register_class

lib/sqlalchemy/orm/instrumentation.py:655–682  ·  view source on GitHub ↗

Register class instrumentation. Returns the existing or newly created class manager.

(
    class_: Type[_O],
    finalize: bool = True,
    mapper: Optional[Mapper[_O]] = None,
    registry: Optional[_RegistryType] = None,
    declarative_scan: Optional[_MapperConfig] = None,
    expired_attribute_loader: Optional[_ExpiredAttributeLoaderProto] = None,
    init_method: Optional[Callable[..., None]] = None,
)

Source from the content-addressed store, hash-verified

653
654
655def register_class(
656 class_: Type[_O],
657 finalize: bool = True,
658 mapper: Optional[Mapper[_O]] = None,
659 registry: Optional[_RegistryType] = None,
660 declarative_scan: Optional[_MapperConfig] = None,
661 expired_attribute_loader: Optional[_ExpiredAttributeLoaderProto] = None,
662 init_method: Optional[Callable[..., None]] = None,
663) -> ClassManager[_O]:
664 """Register class instrumentation.
665
666 Returns the existing or newly created class manager.
667
668 """
669
670 manager = opt_manager_of_class(class_)
671 if manager is None:
672 manager = _instrumentation_factory.create_manager_for_cls(class_)
673 manager._update_state(
674 mapper=mapper,
675 registry=registry,
676 declarative_scan=declarative_scan,
677 expired_attribute_loader=expired_attribute_loader,
678 init_method=init_method,
679 finalize=finalize,
680 )
681
682 return manager
683
684
685def unregister_class(class_):

Callers 15

test_instance_dictMethod · 0.90
test_basicMethod · 0.90
test_deferredMethod · 0.90
test_inheritanceMethod · 0.90
test_historyMethod · 0.90
test_standardMethod · 0.90

Calls 3

opt_manager_of_classFunction · 0.85
_update_stateMethod · 0.80

Tested by 15

test_instance_dictMethod · 0.72
test_basicMethod · 0.72
test_deferredMethod · 0.72
test_inheritanceMethod · 0.72
test_historyMethod · 0.72
test_standardMethod · 0.72