Configure all as-yet unconfigured mappers in this :class:`_orm.registry`. The configure step is used to reconcile and initialize the :func:`_orm.relationship` linkages between mapped classes, as well as to invoke configuration events such as the :meth:`_orm.M
(self, cascade: bool = False)
| 1429 | manager.registry = self |
| 1430 | |
| 1431 | def configure(self, cascade: bool = False) -> None: |
| 1432 | """Configure all as-yet unconfigured mappers in this |
| 1433 | :class:`_orm.registry`. |
| 1434 | |
| 1435 | The configure step is used to reconcile and initialize the |
| 1436 | :func:`_orm.relationship` linkages between mapped classes, as well as |
| 1437 | to invoke configuration events such as the |
| 1438 | :meth:`_orm.MapperEvents.before_configured` and |
| 1439 | :meth:`_orm.MapperEvents.after_configured`, which may be used by ORM |
| 1440 | extensions or user-defined extension hooks. |
| 1441 | |
| 1442 | If one or more mappers in this registry contain |
| 1443 | :func:`_orm.relationship` constructs that refer to mapped classes in |
| 1444 | other registries, this registry is said to be *dependent* on those |
| 1445 | registries. In order to configure those dependent registries |
| 1446 | automatically, the :paramref:`_orm.registry.configure.cascade` flag |
| 1447 | should be set to ``True``. Otherwise, if they are not configured, an |
| 1448 | exception will be raised. The rationale behind this behavior is to |
| 1449 | allow an application to programmatically invoke configuration of |
| 1450 | registries while controlling whether or not the process implicitly |
| 1451 | reaches other registries. |
| 1452 | |
| 1453 | As an alternative to invoking :meth:`_orm.registry.configure`, the ORM |
| 1454 | function :func:`_orm.configure_mappers` function may be used to ensure |
| 1455 | configuration is complete for all :class:`_orm.registry` objects in |
| 1456 | memory. This is generally simpler to use and also predates the usage of |
| 1457 | :class:`_orm.registry` objects overall. However, this function will |
| 1458 | impact all mappings throughout the running Python process and may be |
| 1459 | more memory/time consuming for an application that has many registries |
| 1460 | in use for different purposes that may not be needed immediately. |
| 1461 | |
| 1462 | .. seealso:: |
| 1463 | |
| 1464 | :func:`_orm.configure_mappers` |
| 1465 | |
| 1466 | |
| 1467 | .. versionadded:: 1.4.0b2 |
| 1468 | |
| 1469 | """ |
| 1470 | mapperlib._configure_registries({self}, cascade=cascade) |
| 1471 | |
| 1472 | def dispose(self, cascade: bool = False) -> None: |
| 1473 | """Dispose of all mappers in this :class:`_orm.registry`. |
no outgoing calls