SQLAlchemy 1.1 Documentation
Alternate Class Instrumentation¶
Extensible class instrumentation.
sqlalchemy.ext.instrumentation package provides for alternate
systems of class instrumentation within the ORM. Class instrumentation
refers to how the ORM places attributes on the class which maintain
data and track changes to that data, as well as event hooks installed
on the class.
The extension package is provided for the benefit of integration with other object management packages, which already perform their own instrumentation. It is not intended for general use.
For examples of how the instrumentation extension is used, see the example Attribute Instrumentation.
Changed in version 0.8: The
sqlalchemy.orm.instrumentation was split out so
that all functionality having to do with non-standard
instrumentation was moved out to
When imported, the module installs itself within
sqlalchemy.orm.instrumentation so that it
takes effect, including recognition of
__sa_instrumentation_manager__ on mapped classes, as
being used to determine class instrumentation resolution.
Attribute, elects custom instrumentation when present on a mapped class.
Allows a class to specify a slightly or wildly different technique for tracking changes made to mapped attributes and collections.
Only one instrumentation implementation is allowed in a given object inheritance hierarchy.
The value of this attribute must be a callable and will be passed a class object. The callable must return one of:
- An instance of an InstrumentationManager or subclass
- An object implementing all or some of InstrumentationManager (TODO)
- A dictionary of callables, implementing all or some of the above (TODO)
- An instance of a ClassManager or subclass
This attribute is consulted by SQLAlchemy instrumentation resolution, once the
sqlalchemy.ext.instrumentationmodule has been imported. If custom finders are installed in the global instrumentation_finders list, they may or may not choose to honor this attribute.
Factory for new ClassManager instances.
User-defined class instrumentation extension.
InstrumentationManagercan be subclassed in order to change how class instrumentation proceeds. This class exists for the purposes of integration with other object management frameworks which would like to entirely modify the instrumentation methodology of the ORM, and is not intended for regular usage. For interception of class instrumentation events, see
The API for this class should be considered as semi-stable, and may change slightly with new releases.
install_descriptor(class_, key, inst)¶
install_member(class_, key, implementation)¶
install_state(class_, instance, state)¶
instrument_attribute(class_, key, inst)¶
instrument_collection_class(class_, key, collection_class)¶
post_configure_attribute(class_, key, inst)¶
instrumentation_finders= [<function find_native_user_instrumentation_hook at 0x7feb9aebc7d0>]¶
An extensible sequence of callables which return instrumentation implementations
When a class is registered, each callable will be passed a class object. If None is returned, the next finder in the sequence is consulted. Otherwise the return must be an instrumentation factory that follows the same guidelines as sqlalchemy.ext.instrumentation.INSTRUMENTATION_MANAGER.
By default, the only finder is find_native_user_instrumentation_hook, which searches for INSTRUMENTATION_MANAGER. If all finders return None, standard ClassManager instrumentation is used.
InstrumentationFactorywith additional bookkeeping, to accommodate multiple types of class managers.