(
self,
registry: _RegistryType,
cls_: Type[Any],
mapper_kw: _MapperKwArgs,
)
| 328 | ) |
| 329 | |
| 330 | def __init__( |
| 331 | self, |
| 332 | registry: _RegistryType, |
| 333 | cls_: Type[Any], |
| 334 | mapper_kw: _MapperKwArgs, |
| 335 | ): |
| 336 | self.cls = util.assert_arg_type(cls_, type, "cls_") |
| 337 | self.classname = cls_.__name__ |
| 338 | self.properties = util.OrderedDict() |
| 339 | self.declared_attr_reg = {} |
| 340 | |
| 341 | if not mapper_kw.get("non_primary", False): |
| 342 | instrumentation.register_class( |
| 343 | self.cls, |
| 344 | finalize=False, |
| 345 | registry=registry, |
| 346 | declarative_scan=self, |
| 347 | init_method=registry.constructor, |
| 348 | ) |
| 349 | else: |
| 350 | manager = attributes.opt_manager_of_class(self.cls) |
| 351 | if not manager or not manager.is_mapped: |
| 352 | raise exc.InvalidRequestError( |
| 353 | "Class %s has no primary mapper configured. Configure " |
| 354 | "a primary mapper first before setting up a non primary " |
| 355 | "Mapper." % self.cls |
| 356 | ) |
| 357 | |
| 358 | def set_cls_attribute(self, attrname: str, value: _T) -> _T: |
| 359 | manager = instrumentation.manager_of_class(self.cls) |
no test coverage detected