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

Méthode sqlalchemy.orm.AttributeEvents.set

Signature de la méthode set

def set(self, target, value, oldvalue, initiator) 

Description

set.__doc__

Receive a scalar set event.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass.some_attribute, 'set')
        def receive_set(target, value, oldvalue, initiator):
            "listen for the 'set' event"

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


:param target: the object instance receiving the event.
  If the listener is registered with ``raw=True``, this will
  be the :class:`.InstanceState` object.
:param value: the value being set.  If this listener
  is registered with ``retval=True``, the listener
  function must return this value, or a new value which
  replaces it.
:param oldvalue: the previous value being replaced.  This
  may also be the symbol ``NEVER_SET`` or ``NO_VALUE``.
  If the listener is registered with ``active_history=True``,
  the previous value of the attribute will be loaded from
  the database if the existing value is currently unloaded
  or expired.
:param initiator: An instance of :class:`.attributes.Event`
  representing the initiation of the event.  May be modified
  from its original value by backref handlers in order to control
  chained event propagation.

  .. versionchanged:: 0.9.0 the ``initiator`` argument is now
     passed as a :class:`.attributes.Event` object, and may be
     modified by backref handlers within a chain of backref-linked
     events.

:return: if the event was registered with ``retval=True``,
 the given value, or a new effective value, should be returned.

.. seealso::

    :class:`.AttributeEvents` - background on listener options such
    as propagation to subclasses.