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

Signature de la méthode append

def append(self, target, value, initiator) 

Description

append.__doc__

Receive a collection append event.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass.some_attribute, 'append')
        def receive_append(target, value, initiator):
            "listen for the 'append' event"

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


The append event is invoked for each element as it is appended
to the collection.  This occurs for single-item appends as well
as for a "bulk replace" operation.

: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 appended.  If this listener
  is registered with ``retval=True``, the listener
  function must return this value, or a new value which
  replaces it.
: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, as well as be inspected for information
  about the source of the event.
: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.

    :meth:`.AttributeEvents.bulk_replace`