MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / after_mapper_constructed

Method after_mapper_constructed

lib/sqlalchemy/orm/events.py:945–977  ·  view source on GitHub ↗

Receive a class and mapper when the :class:`_orm.Mapper` has been fully constructed. This event is called after the initial constructor for :class:`_orm.Mapper` completes. This occurs after the :meth:`_orm.MapperEvents.instrument_class` event and after the :

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

Source from the content-addressed store, hash-verified

943 """
944
945 def after_mapper_constructed(
946 self, mapper: Mapper[_O], class_: Type[_O]
947 ) -> None:
948 """Receive a class and mapper when the :class:`_orm.Mapper` has been
949 fully constructed.
950
951 This event is called after the initial constructor for
952 :class:`_orm.Mapper` completes. This occurs after the
953 :meth:`_orm.MapperEvents.instrument_class` event and after the
954 :class:`_orm.Mapper` has done an initial pass of its arguments
955 to generate its collection of :class:`_orm.MapperProperty` objects,
956 which are accessible via the :meth:`_orm.Mapper.get_property`
957 method and the :attr:`_orm.Mapper.iterate_properties` attribute.
958
959 This event differs from the
960 :meth:`_orm.MapperEvents.before_mapper_configured` event in that it
961 is invoked within the constructor for :class:`_orm.Mapper`, rather
962 than within the :meth:`_orm.registry.configure` process. Currently,
963 this event is the only one which is appropriate for handlers that
964 wish to create additional mapped classes in response to the
965 construction of this :class:`_orm.Mapper`, which will be part of the
966 same configure step when :meth:`_orm.registry.configure` next runs.
967
968 .. versionadded:: 2.0.2
969
970 .. seealso::
971
972 :ref:`examples_versioning` - an example which illustrates the use
973 of the :meth:`_orm.MapperEvents.before_mapper_configured`
974 event to create new mappers to record change-audit histories on
975 objects.
976
977 """
978
979 @event._omit_standard_example
980 def before_mapper_configured(

Callers 2

__init__Method · 0.80

Calls

no outgoing calls

Tested by 1