MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / mapper_configured

Method mapper_configured

lib/sqlalchemy/orm/events.py:1011–1066  ·  view source on GitHub ↗

r"""Called when a specific mapper has completed its own configuration within the scope of the :func:`.configure_mappers` call. The :meth:`.MapperEvents.mapper_configured` event is invoked for each mapper that is encountered when the :func:`_orm.configure_mappers` fun

(self, mapper: Mapper[_O], class_: Type[_O])

Source from the content-addressed store, hash-verified

1009 """
1010
1011 def mapper_configured(self, mapper: Mapper[_O], class_: Type[_O]) -> None:
1012 r"""Called when a specific mapper has completed its own configuration
1013 within the scope of the :func:`.configure_mappers` call.
1014
1015 The :meth:`.MapperEvents.mapper_configured` event is invoked
1016 for each mapper that is encountered when the
1017 :func:`_orm.configure_mappers` function proceeds through the current
1018 list of not-yet-configured mappers.
1019 :func:`_orm.configure_mappers` is typically invoked
1020 automatically as mappings are first used, as well as each time
1021 new mappers have been made available and new mapper use is
1022 detected.
1023
1024 When the event is called, the mapper should be in its final
1025 state, but **not including backrefs** that may be invoked from
1026 other mappers; they might still be pending within the
1027 configuration operation. Bidirectional relationships that
1028 are instead configured via the
1029 :paramref:`.orm.relationship.back_populates` argument
1030 *will* be fully available, since this style of relationship does not
1031 rely upon other possibly-not-configured mappers to know that they
1032 exist.
1033
1034 For an event that is guaranteed to have **all** mappers ready
1035 to go including backrefs that are defined only on other
1036 mappings, use the :meth:`.MapperEvents.after_configured`
1037 event; this event invokes only after all known mappings have been
1038 fully configured.
1039
1040 The :meth:`.MapperEvents.mapper_configured` event, unlike the
1041 :meth:`.MapperEvents.before_configured` or
1042 :meth:`.MapperEvents.after_configured` events, is called for each
1043 mapper/class individually, and the mapper is passed to the event
1044 itself. It also is called exactly once for a particular mapper. The
1045 event is therefore useful for configurational steps that benefit from
1046 being invoked just once on a specific mapper basis, which don't require
1047 that "backref" configurations are necessarily ready yet.
1048
1049 :param mapper: the :class:`_orm.Mapper` which is the target
1050 of this event.
1051 :param class\_: the mapped class.
1052
1053 .. seealso::
1054
1055 :meth:`.MapperEvents.before_configured`
1056
1057 :meth:`.MapperEvents.after_configured`
1058
1059 :meth:`.RegistryEvents.before_configured`
1060
1061 :meth:`.RegistryEvents.after_configured`
1062
1063 :meth:`.MapperEvents.before_mapper_configured`
1064
1065 """
1066 # TODO: need coverage for this event
1067
1068 @event._omit_standard_example

Callers 1

_do_configure_registriesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected