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 « SessionEvents »

Informations générales

Héritage

builtins.object
    Events
        SessionEvents

Définition

class SessionEvents(Events):

Description [extrait de SessionEvents.__doc__]

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 0x7f40cb8a0150>

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
after_attach(self, session, instance) Execute after an instance is attached to a session. [extrait de after_attach.__doc__]
after_begin(self, session, transaction, connection) Execute after a transaction is begun on a connection [extrait de after_begin.__doc__]
after_bulk_delete(self, delete_context) Execute after ORM DELETE against a WHERE expression has been [extrait de after_bulk_delete.__doc__]
after_bulk_update(self, update_context) Execute after an ORM UPDATE against a WHERE expression has been [extrait de after_bulk_update.__doc__]
after_commit(self, session) Execute after a commit has occurred. [extrait de after_commit.__doc__]
after_flush(self, session, flush_context) Execute after flush has completed, but before commit has been [extrait de after_flush.__doc__]
after_flush_postexec(self, session, flush_context) Execute after flush has completed, and after the post-exec [extrait de after_flush_postexec.__doc__]
after_rollback(self, session) Execute after a real DBAPI rollback has occurred. [extrait de after_rollback.__doc__]
after_soft_rollback(self, session, previous_transaction) Execute after any rollback has occurred, including "soft" [extrait de after_soft_rollback.__doc__]
after_transaction_create(self, session, transaction) Execute when a new :class:`.SessionTransaction` is created. [extrait de after_transaction_create.__doc__]
after_transaction_end(self, session, transaction) Execute when the span of a :class:`.SessionTransaction` ends. [extrait de after_transaction_end.__doc__]
before_attach(self, session, instance) Execute before an instance is attached to a session. [extrait de before_attach.__doc__]
before_commit(self, session) Execute before commit is called. [extrait de before_commit.__doc__]
before_flush(self, session, flush_context, instances) Execute before flush process has started. [extrait de before_flush.__doc__]
deleted_to_detached(self, session, instance) Intercept the "deleted to detached" transition for a specific object. [extrait de deleted_to_detached.__doc__]
deleted_to_persistent(self, session, instance) Intercept the "deleted to persistent" transition for a specific object. [extrait de deleted_to_persistent.__doc__]
detached_to_persistent(self, session, instance) Intercept the "detached to persistent" transition for a specific object. [extrait de detached_to_persistent.__doc__]
do_orm_execute(self, orm_execute_state) Intercept statement executions that occur in terms of a :class:`.Session`. [extrait de do_orm_execute.__doc__]
loaded_as_persistent(self, session, instance) Intercept the "loaded as persistent" transition for a specific object. [extrait de loaded_as_persistent.__doc__]
pending_to_persistent(self, session, instance) Intercept the "pending to persistent"" transition for a specific object. [extrait de pending_to_persistent.__doc__]
pending_to_transient(self, session, instance) Intercept the "pending to transient" transition for a specific object. [extrait de pending_to_transient.__doc__]
persistent_to_deleted(self, session, instance) Intercept the "persistent to deleted" transition for a specific object. [extrait de persistent_to_deleted.__doc__]
persistent_to_detached(self, session, instance) Intercept the "persistent to detached" transition for a specific object. [extrait de persistent_to_detached.__doc__]
persistent_to_transient(self, session, instance) Intercept the "persistent to transient" transition for a specific object. [extrait de persistent_to_transient.__doc__]
transient_to_pending(self, session, instance) Intercept the "transient to pending" transition for a specific object. [extrait de transient_to_pending.__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__