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.
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`
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 :