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,
)
| 653 | |
| 654 | |
| 655 | def 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 | |
| 685 | def unregister_class(class_): |