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 :

Vous êtes un professionnel et vous avez besoin d'une formation ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé
Classe « AttributeEvents »

Méthode sqlalchemy.orm.AttributeEvents.append_wo_mutation

Signature de la méthode append_wo_mutation

def append_wo_mutation(self, target: '_O', value: '_T', initiator: 'Event', *, key: 'EventConstants' = <EventConstants.NO_KEY: 4>) -> 'None' 

Description

help(AttributeEvents.append_wo_mutation)

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.
:param key: When the event is established using the
 :paramref:`.AttributeEvents.include_key` parameter set to
 True, this will be the key used in the operation, such as
 ``collection[some_key_or_index] = value``.
 The parameter is not passed
 to the event at all if the the
 :paramref:`.AttributeEvents.include_key`
 was not used to set up the event; this is to allow backwards
 compatibility with existing event handlers that don't include the
 ``key`` parameter.

 .. versionadded:: 2.0

:return: No return value is defined for this event.

.. versionadded:: 1.4.15



Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé