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 ? Calcul scientifique
avec Python
Voir le programme détaillé
Module « sqlalchemy.orm »

Classe « InstanceEvents »

Informations générales

Héritage

builtins.object
    Generic
        _HasEventsDispatch
            Events
                InstanceEvents

Définition

class InstanceEvents(Events):

help(InstanceEvents)

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 indicates 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 0x0000020D9F45D310>

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
__class_getitem__ Parameterizes a generic class. [extrait de __class_getitem__.__doc__]
expire(self, target: '_O', attrs: 'Optional[Iterable[str]]') -> 'None' Receive an object instance after its attributes or some subset [extrait de expire.__doc__]
first_init(self, manager: 'ClassManager[_O]', cls: 'Type[_O]') -> 'None' Called when the first instance of a particular mapping is called. [extrait de first_init.__doc__]
init(self, target: '_O', args: 'Any', kwargs: 'Any') -> 'None' Receive an instance when its constructor is called. [extrait de init.__doc__]
init_failure(self, target: '_O', args: 'Any', kwargs: 'Any') -> 'None' Receive an instance when its constructor has been called, [extrait de init_failure.__doc__]
load(self, target: '_O', context: 'QueryContext') -> 'None' Receive an object instance after it has been created via [extrait de load.__doc__]
pickle(self, target: '_O', state_dict: '_InstanceDict') -> 'None' Receive an object instance when its associated state is [extrait de pickle.__doc__]
refresh(self, target: '_O', context: 'QueryContext', attrs: 'Optional[Iterable[str]]') -> 'None' Receive an object instance after one or more attributes have [extrait de refresh.__doc__]
refresh_flush(self, target: '_O', flush_context: 'UOWTransaction', attrs: 'Optional[Iterable[str]]') -> 'None' Receive an object instance after one or more attributes that [extrait de refresh_flush.__doc__]
unpickle(self, target: '_O', state_dict: '_InstanceDict') -> 'None' Receive an object instance after its associated state has [extrait de unpickle.__doc__]

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

__subclasshook__

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

__init_subclass__

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

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

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé