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é
Classe « MapperEvents »

Méthode sqlalchemy.orm.MapperEvents.instrument_class

Signature de la méthode instrument_class

def instrument_class(self, mapper: 'Mapper[_O]', class_: 'Type[_O]') -> 'None' 

Description

help(MapperEvents.instrument_class)

Receive a class when the mapper is first constructed,
before instrumentation is applied to the mapped class.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeClass, 'instrument_class')
        def receive_instrument_class(mapper, class_):
            "listen for the 'instrument_class' event"

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


This event is the earliest phase of mapper construction.
Most attributes of the mapper are not yet initialized.   To
receive an event within initial mapper construction where basic
state is available such as the :attr:`_orm.Mapper.attrs` collection,
the :meth:`_orm.MapperEvents.after_mapper_constructed` event may
be a better choice.

This listener can either be applied to the :class:`_orm.Mapper`
class overall, or to any un-mapped class which serves as a base
for classes that will be mapped (using the ``propagate=True`` flag)::

    Base = declarative_base()


    @event.listens_for(Base, "instrument_class", propagate=True)
    def on_new_class(mapper, cls_):
        "..."

:param mapper: the :class:`_orm.Mapper` which is the target
 of this event.
:param class\_: the mapped class.

.. seealso::

    :meth:`_orm.MapperEvents.after_mapper_constructed`



Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé