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.after_configured

Signature de la méthode after_configured

def after_configured(self) 

Description

after_configured.__doc__

Called after a series of mappers have been configured.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'after_configured')
        def receive_after_configured():
            "listen for the 'after_configured' event"

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


The :meth:`.MapperEvents.after_configured` event is invoked
each time the :func:`_orm.configure_mappers` function is
invoked, after the function has completed its work.
: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.

Contrast this event to the :meth:`.MapperEvents.mapper_configured`
event, which is called on a per-mapper basis while the configuration
operation proceeds; unlike that event, when this event is invoked,
all cross-configurations (e.g. backrefs) will also have been made
available for any mappers that were pending.
Also contrast to :meth:`.MapperEvents.before_configured`,
which is invoked before the series of mappers has been configured.

This event can **only** be applied to the :class:`_orm.Mapper` class
or :func:`.mapper` function, and not to individual mappings or
mapped classes.  It is only invoked for all mappings as a whole::

    from sqlalchemy.orm import mapper

    @event.listens_for(mapper, "after_configured")
    def go():
        # ...

Theoretically this event is called once per
application, but is actually called any time new mappers
have been affected by a :func:`_orm.configure_mappers`
call.   If new mappings are constructed after existing ones have
already been used, this event will likely be called again.  To ensure
that a particular event is only called once and no further, the
``once=True`` argument (new in 0.9.4) can be applied::

    from sqlalchemy.orm import mapper

    @event.listens_for(mapper, "after_configured", once=True)
    def go():
        # ...

.. seealso::

    :meth:`.MapperEvents.before_mapper_configured`

    :meth:`.MapperEvents.mapper_configured`

    :meth:`.MapperEvents.before_configured`