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 :

Module « sqlalchemy.orm »

Classe « InstanceEvents »

Informations générales

Héritage

builtins.object
    Events
        InstanceEvents

Définition

class InstanceEvents(Events):

Description [extrait de InstanceEvents.__doc__]

Define events specific to object lifecycle.

    e.g.::

        from sqlalchemy import event

        def my_load_listener(target, context):
            print("on load!")

        event.listen(SomeClass, 'load', my_load_listener)

    Available targets include:

    * mapped classes
    * unmapped superclasses of mapped or to-be-mapped classes
      (using the ``propagate=True`` flag)
    * :class:`_orm.Mapper` objects
    * the :class:`_orm.Mapper` class itself and the :func:`.mapper`
      function indicate listening for all mappers.

    Instance events are closely related to mapper events, but
    are more specific to the instance and its instrumentation,
    rather than its system of persistence.

    When using :class:`.InstanceEvents`, several modifiers are
    available to the :func:`.event.listen` function.

    :param propagate=False: When True, the event listener should
       be applied to all inheriting classes as well as the
       class which is the target of this listener.
    :param raw=False: When True, the "target" argument passed
       to applicable event listener functions will be the
       instance's :class:`.InstanceState` management
       object, rather than the mapped instance itself.
    :param restore_load_context=False: Applies to the
       :meth:`.InstanceEvents.load` and :meth:`.InstanceEvents.refresh`
       events.  Restores the loader context of the object when the event
       hook is complete, so that ongoing eager load operations continue
       to target the object appropriately.  A warning is emitted if the
       object is moved to a new loader context from within one of these
       events if this flag is not set.

       .. versionadded:: 1.3.14


    

Constructeur(s)

Signature du constructeur Description
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
dispatch<sqlalchemy.event.base.InstanceEventsDispatch object at 0x7f40cb8b00d0>

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
expire(self, target, attrs) Receive an object instance after its attributes or some subset [extrait de expire.__doc__]
first_init(self, manager, cls) Called when the first instance of a particular mapping is called. [extrait de first_init.__doc__]
init(self, target, args, kwargs) Receive an instance when its constructor is called. [extrait de init.__doc__]
init_failure(self, target, args, kwargs) Receive an instance when its constructor has been called, [extrait de init_failure.__doc__]
load(self, target, context) Receive an object instance after it has been created via [extrait de load.__doc__]
pickle(self, target, state_dict) Receive an object instance when its associated state is [extrait de pickle.__doc__]
refresh(self, target, context, attrs) Receive an object instance after one or more attributes have [extrait de refresh.__doc__]
refresh_flush(self, target, flush_context, attrs) Receive an object instance after one or more attributes that [extrait de refresh_flush.__doc__]
unpickle(self, target, state_dict) Receive an object instance after its associated state has [extrait de unpickle.__doc__]

Méthodes héritées de la classe Events

__init_subclass__, __subclasshook__

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__