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

Méthode sqlalchemy.orm.InstanceEvents.init

Signature de la méthode init

def init(self, target, args, kwargs) 

Description

init.__doc__

Receive an instance when its constructor is called.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'init')
        def receive_init(target, args, kwargs):
            "listen for the 'init' event"

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


This method is only called during a userland construction of
an object, in conjunction with the object's constructor, e.g.
its ``__init__`` method.  It is not called when an object is
loaded from the database; see the :meth:`.InstanceEvents.load`
event in order to intercept a database load.

The event is called before the actual ``__init__`` constructor
of the object is called.  The ``kwargs`` dictionary may be
modified in-place in order to affect what is passed to
``__init__``.

:param target: the mapped instance.  If
 the event is configured with ``raw=True``, this will
 instead be the :class:`.InstanceState` state-management
 object associated with the instance.
:param args: positional arguments passed to the ``__init__`` method.
 This is passed as a tuple and is currently immutable.
:param kwargs: keyword arguments passed to the ``__init__`` method.
 This structure *can* be altered in place.

.. seealso::

    :meth:`.InstanceEvents.init_failure`

    :meth:`.InstanceEvents.load`