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 « InstanceEvents »

Méthode sqlalchemy.orm.InstanceEvents.refresh

Signature de la méthode refresh

def refresh(self, target, context, attrs) 

Description

refresh.__doc__

Receive an object instance after one or more attributes have
been refreshed from a query.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'refresh')
        def receive_refresh(target, context, attrs):
            "listen for the 'refresh' event"

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


Contrast this to the :meth:`.InstanceEvents.load` method, which
is invoked when the object is first loaded from a query.

.. note:: This event is invoked within the loader process before
   eager loaders may have been completed, and the object's state may
   not be complete.  Additionally, invoking row-level refresh
   operations on the object will place the object into a new loader
   context, interfering with the existing load context.   See the note
   on :meth:`.InstanceEvents.load` for background on making use of the
   :paramref:`.InstanceEvents.restore_load_context` parameter, in
   order to resolve this scenario.

:param target: the mapped instance.  If
 the event is configured with ``raw=True``, this will
 instead be the :class:`.InstanceState` state-management
 object associated with the instance.
:param context: the :class:`.QueryContext` corresponding to the
 current :class:`_query.Query` in progress.
:param attrs: sequence of attribute names which
 were populated, or None if all column-mapped, non-deferred
 attributes were populated.

.. seealso::

    :meth:`.InstanceEvents.load`