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

Signature de la méthode dispose_collection

def dispose_collection(self, target, collection, collection_adapter) 

Description

dispose_collection.__doc__

Receive a 'collection dispose' event.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass.some_attribute, 'dispose_collection')
        def receive_dispose_collection(target, collection, collection_adapter):
            "listen for the 'dispose_collection' event"

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


This event is triggered for a collection-based attribute when
a collection is replaced, that is::

    u1.addresses.append(a1)

    u1.addresses = [a2, a3]  # <- old collection is disposed

The old collection received will contain its previous contents.

.. versionchanged:: 1.2 The collection passed to
   :meth:`.AttributeEvents.dispose_collection` will now have its
   contents before the dispose intact; previously, the collection
   would be empty.

.. versionadded:: 1.0.0 the :meth:`.AttributeEvents.init_collection`
   and :meth:`.AttributeEvents.dispose_collection` events.

.. seealso::

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