(
registries: Set[_RegistryType], cascade: bool
)
| 4233 | |
| 4234 | @util.preload_module("sqlalchemy.orm.decl_api") |
| 4235 | def _do_configure_registries( |
| 4236 | registries: Set[_RegistryType], cascade: bool |
| 4237 | ) -> None: |
| 4238 | registry = util.preloaded.orm_decl_api.registry |
| 4239 | |
| 4240 | orig = set(registries) |
| 4241 | |
| 4242 | for reg in registry._recurse_with_dependencies(registries): |
| 4243 | has_skip = False |
| 4244 | |
| 4245 | for mapper in reg._mappers_to_configure(): |
| 4246 | run_configure = None |
| 4247 | |
| 4248 | for fn in mapper.dispatch.before_mapper_configured: |
| 4249 | run_configure = fn(mapper, mapper.class_) |
| 4250 | if run_configure is EXT_SKIP: |
| 4251 | has_skip = True |
| 4252 | break |
| 4253 | if run_configure is EXT_SKIP: |
| 4254 | continue |
| 4255 | |
| 4256 | if getattr(mapper, "_configure_failed", False): |
| 4257 | e = sa_exc.InvalidRequestError( |
| 4258 | "One or more mappers failed to initialize - " |
| 4259 | "can't proceed with initialization of other " |
| 4260 | "mappers. Triggering mapper: '%s'. " |
| 4261 | "Original exception was: %s" |
| 4262 | % (mapper, mapper._configure_failed) |
| 4263 | ) |
| 4264 | e._configure_failed = mapper._configure_failed # type: ignore |
| 4265 | raise e |
| 4266 | |
| 4267 | if not mapper.configured: |
| 4268 | try: |
| 4269 | mapper._post_configure_properties() |
| 4270 | mapper._expire_memoizations() |
| 4271 | mapper.dispatch.mapper_configured(mapper, mapper.class_) |
| 4272 | except Exception: |
| 4273 | exc = sys.exc_info()[1] |
| 4274 | if not hasattr(exc, "_configure_failed"): |
| 4275 | mapper._configure_failed = exc |
| 4276 | raise |
| 4277 | if not has_skip: |
| 4278 | reg._new_mappers = False |
| 4279 | |
| 4280 | if not cascade and reg._dependencies.difference(orig): |
| 4281 | raise sa_exc.InvalidRequestError( |
| 4282 | "configure was called with cascade=False but " |
| 4283 | "additional registries remain" |
| 4284 | ) |
| 4285 | |
| 4286 | |
| 4287 | @util.preload_module("sqlalchemy.orm.decl_api") |
no test coverage detected