MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / register_class

Function register_class

lib/sqlalchemy/orm/instrumentation.py:663–690  ·  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

661
662
663def register_class(
664 class_: Type[_O],
665 finalize: bool = True,
666 mapper: Optional[Mapper[_O]] = None,
667 registry: Optional[_RegistryType] = None,
668 declarative_scan: Optional[_MapperConfig] = None,
669 expired_attribute_loader: Optional[_ExpiredAttributeLoaderProto] = None,
670 init_method: Optional[Callable[..., None]] = None,
671) -> ClassManager[_O]:
672 """Register class instrumentation.
673
674 Returns the existing or newly created class manager.
675
676 """
677
678 manager = opt_manager_of_class(class_)
679 if manager is None:
680 manager = _instrumentation_factory.create_manager_for_cls(class_)
681 manager._update_state(
682 mapper=mapper,
683 registry=registry,
684 declarative_scan=declarative_scan,
685 expired_attribute_loader=expired_attribute_loader,
686 init_method=init_method,
687 finalize=finalize,
688 )
689
690 return manager
691
692
693def 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