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_flush

Signature de la méthode refresh_flush

def refresh_flush(self, target, flush_context, attrs) 

Description

refresh_flush.__doc__

Receive an object instance after one or more attributes that
contain a column-level default or onupdate handler have been refreshed
during persistence of the object's state.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'refresh_flush')
        def receive_refresh_flush(target, flush_context, attrs):
            "listen for the 'refresh_flush' event"

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


This event is the same as :meth:`.InstanceEvents.refresh` except
it is invoked within the unit of work flush process, and includes
only non-primary-key columns that have column level default or
onupdate handlers, including Python callables as well as server side
defaults and triggers which may be fetched via the RETURNING clause.

.. note::

    While the :meth:`.InstanceEvents.refresh_flush` event is triggered
    for an object that was INSERTed as well as for an object that was
    UPDATEd, the event is geared primarily  towards the UPDATE process;
    it is mostly an internal artifact that INSERT actions can also
    trigger this event, and note that **primary key columns for an
    INSERTed row are explicitly omitted** from this event.  In order to
    intercept the newly INSERTed state of an object, the
    :meth:`.SessionEvents.pending_to_persistent` and
    :meth:`.MapperEvents.after_insert` are better choices.

.. versionadded:: 1.0.5

: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 flush_context: Internal :class:`.UOWTransaction` object
 which handles the details of the flush.
:param attrs: sequence of attribute names which
 were populated.

.. seealso::

    :ref:`orm_server_defaults`

    :ref:`metadata_defaults_toplevel`