Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Classe « MapperEvents »

Méthode sqlalchemy.orm.MapperEvents.mapper_configured

Signature de la méthode mapper_configured

def mapper_configured(self, mapper, class_) 

Description

mapper_configured.__doc__

Called when a specific mapper has completed its own configuration
within the scope of the :func:`.configure_mappers` call.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'mapper_configured')
        def receive_mapper_configured(mapper, class_):
            "listen for the 'mapper_configured' event"

            # ... (event handling logic) ...


The :meth:`.MapperEvents.mapper_configured` event is invoked
for each mapper that is encountered when the
:func:`_orm.configure_mappers` function proceeds through the current
list of not-yet-configured mappers.
:func:`_orm.configure_mappers` is typically invoked
automatically as mappings are first used, as well as each time
new mappers have been made available and new mapper use is
detected.

When the event is called, the mapper should be in its final
state, but **not including backrefs** that may be invoked from
other mappers; they might still be pending within the
configuration operation.    Bidirectional relationships that
are instead configured via the
:paramref:`.orm.relationship.back_populates` argument
*will* be fully available, since this style of relationship does not
rely upon other possibly-not-configured mappers to know that they
exist.

For an event that is guaranteed to have **all** mappers ready
to go including backrefs that are defined only on other
mappings, use the :meth:`.MapperEvents.after_configured`
event; this event invokes only after all known mappings have been
fully configured.

The :meth:`.MapperEvents.mapper_configured` event, unlike
:meth:`.MapperEvents.before_configured` or
:meth:`.MapperEvents.after_configured`,
is called for each mapper/class individually, and the mapper is
passed to the event itself.  It also is called exactly once for
a particular mapper.  The event is therefore useful for
configurational steps that benefit from being invoked just once
on a specific mapper basis, which don't require that "backref"
configurations are necessarily ready yet.

:param mapper: the :class:`_orm.Mapper` which is the target
 of this event.
:param class\_: the mapped class.

.. seealso::

    :meth:`.MapperEvents.before_configured`

    :meth:`.MapperEvents.after_configured`

    :meth:`.MapperEvents.before_mapper_configured`