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 ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « sqlalchemy.orm »

Classe « SessionEvents »

Informations générales

Héritage

builtins.object
    Generic
        _HasEventsDispatch
            Events
                SessionEvents

Définition

class SessionEvents(Events):

help(SessionEvents)

Define events specific to :class:`.Session` lifecycle.

e.g.::

    from sqlalchemy import event
    from sqlalchemy.orm import sessionmaker


    def my_before_commit(session):
        print("before commit!")


    Session = sessionmaker()

    event.listen(Session, "before_commit", my_before_commit)

The :func:`~.event.listen` function will accept
:class:`.Session` objects as well as the return result
of :class:`~.sessionmaker()` and :class:`~.scoped_session()`.

Additionally, it accepts the :class:`.Session` class which
will apply listeners to all :class:`.Session` instances
globally.

:param raw=False: When True, the "target" argument passed
   to applicable event listener functions that work on individual
   objects will be the instance's :class:`.InstanceState` management
   object, rather than the mapped instance itself.

   .. versionadded:: 1.3.14

:param restore_load_context=False: Applies to the
   :meth:`.SessionEvents.loaded_as_persistent` event.  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 this event 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.SessionEventsDispatch object at 0x0000020DA13367A0>

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__]
after_attach(self, session: 'Session', instance: '_O') -> 'None' Execute after an instance is attached to a session. [extrait de after_attach.__doc__]
after_begin(self, session: 'Session', transaction: 'SessionTransaction', connection: 'Connection') -> 'None' Execute after a transaction is begun on a connection. [extrait de after_begin.__doc__]
after_bulk_delete(self, delete_context: '_O') -> 'None' Event for after the legacy :meth:`_orm.Query.delete` method [extrait de after_bulk_delete.__doc__]
after_bulk_update(self, update_context: '_O') -> 'None' Event for after the legacy :meth:`_orm.Query.update` method [extrait de after_bulk_update.__doc__]
after_commit(self, session: 'Session') -> 'None' Execute after a commit has occurred. [extrait de after_commit.__doc__]
after_flush(self, session: 'Session', flush_context: 'UOWTransaction') -> 'None' Execute after flush has completed, but before commit has been [extrait de after_flush.__doc__]
after_flush_postexec(self, session: 'Session', flush_context: 'UOWTransaction') -> 'None' Execute after flush has completed, and after the post-exec [extrait de after_flush_postexec.__doc__]
after_rollback(self, session: 'Session') -> 'None' Execute after a real DBAPI rollback has occurred. [extrait de after_rollback.__doc__]
after_soft_rollback(self, session: 'Session', previous_transaction: 'SessionTransaction') -> 'None' Execute after any rollback has occurred, including "soft" [extrait de after_soft_rollback.__doc__]
after_transaction_create(self, session: 'Session', transaction: 'SessionTransaction') -> 'None' Execute when a new :class:`.SessionTransaction` is created. [extrait de after_transaction_create.__doc__]
after_transaction_end(self, session: 'Session', transaction: 'SessionTransaction') -> 'None' Execute when the span of a :class:`.SessionTransaction` ends. [extrait de after_transaction_end.__doc__]
before_attach(self, session: 'Session', instance: '_O') -> 'None' Execute before an instance is attached to a session. [extrait de before_attach.__doc__]
before_commit(self, session: 'Session') -> 'None' Execute before commit is called. [extrait de before_commit.__doc__]
before_flush(self, session: 'Session', flush_context: 'UOWTransaction', instances: 'Optional[Sequence[_O]]') -> 'None' Execute before flush process has started. [extrait de before_flush.__doc__]
deleted_to_detached(self, session: 'Session', instance: '_O') -> 'None' Intercept the "deleted to detached" transition for a specific [extrait de deleted_to_detached.__doc__]
deleted_to_persistent(self, session: 'Session', instance: '_O') -> 'None' Intercept the "deleted to persistent" transition for a specific [extrait de deleted_to_persistent.__doc__]
detached_to_persistent(self, session: 'Session', instance: '_O') -> 'None' Intercept the "detached to persistent" transition for a specific [extrait de detached_to_persistent.__doc__]
do_orm_execute(self, orm_execute_state: 'ORMExecuteState') -> 'None' Intercept statement executions that occur on behalf of an [extrait de do_orm_execute.__doc__]
loaded_as_persistent(self, session: 'Session', instance: '_O') -> 'None' Intercept the "loaded as persistent" transition for a specific [extrait de loaded_as_persistent.__doc__]
pending_to_persistent(self, session: 'Session', instance: '_O') -> 'None' Intercept the "pending to persistent"" transition for a specific [extrait de pending_to_persistent.__doc__]
pending_to_transient(self, session: 'Session', instance: '_O') -> 'None' Intercept the "pending to transient" transition for a specific [extrait de pending_to_transient.__doc__]
persistent_to_deleted(self, session: 'Session', instance: '_O') -> 'None' Intercept the "persistent to deleted" transition for a specific [extrait de persistent_to_deleted.__doc__]
persistent_to_detached(self, session: 'Session', instance: '_O') -> 'None' Intercept the "persistent to detached" transition for a specific [extrait de persistent_to_detached.__doc__]
persistent_to_transient(self, session: 'Session', instance: '_O') -> 'None' Intercept the "persistent to transient" transition for a specific [extrait de persistent_to_transient.__doc__]
transient_to_pending(self, session: 'Session', instance: '_O') -> 'None' Intercept the "transient to pending" transition for a specific [extrait de transient_to_pending.__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 ? Calcul scientifique
avec Python
Voir le programme détaillé