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_wo_mutation

Signature de la méthode append_wo_mutation

def append_wo_mutation(self, target, value, initiator) 

Description

append_wo_mutation.__doc__

Receive a collection append event where the collection was not
actually mutated.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


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

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


This event differs from :meth:`_orm.AttributeEvents.append` in that
it is fired off for de-duplicating collections such as sets and
dictionaries, when the object already exists in the target collection.
The event does not have a return value and the identity of the
given object cannot be changed.

The event is used for cascading objects into a :class:`_orm.Session`
when the collection has already been mutated via a backref event.

: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 that would be appended if the object did not
  already exist in the collection.
: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: No return value is defined for this event.

.. versionadded:: 1.4.15