替代类插桩¶
可扩展的类插桩。
该 sqlalchemy.ext.instrumentation
包在 ORM 中提供了类 instrumentation 的替代系统。类插桩是指 ORM 如何在类上放置维护数据并跟踪该数据更改的属性,以及类上安装的事件钩子。
注意
提供扩展包是为了与其他对象管理包集成,这些包已经执行了自己的检测。它不用于一般用途。
有关如何使用检测扩展的示例,请参阅示例 Attribute Instrumentation。
API 参考¶
对象名称 |
描述 |
---|---|
|
|
|
|
|
|
|
|
|
-
sqlalchemy.ext.instrumentation 的 INSTRUMENTATION_MANAGER = '__sa_instrumentation_manager__'¶
Attribute 时,选择存在于映射类上的自定义插桩。
允许类指定一种略有不同或截然不同的技术来跟踪对映射的属性和集合所做的更改。
在给定的对象继承层次结构中,只允许一个插桩实现。
此属性的值必须是可调用对象,并将传递一个类对象。可调用对象必须返回以下之一:InstrumentationManager
或子类的实例
实现全部或部分 InstrumentationManager (TODO) 的对象
可调用对象的字典,实现上述全部或部分 (TODO)ClassManager
或子类的实例
导入sqlalchemy.ext.instrumentation
模块后,SQLAlchemy 检测解析将查询此属性。如果自定义查找器安装在全局查找器列表中instrumentation_finders则它们可能会也可能不会选择遵循此属性。
-
类 sqlalchemy.orm.instrumentation 中。InstrumentationFactory(仪表工厂)¶
新 ClassManager 实例的 Factory 实例。
类签名
类sqlalchemy.orm.instrumentation.InstrumentationFactory
(sqlalchemy.event.registry.EventTarget
)
-
类 sqlalchemy.ext.instrumentation 中。InstrumentationManager(仪表管理器)¶
用户定义的类插桩扩展。InstrumentationManager
可以子类化,以更改类 instrumentation 的处理方式。此类的存在是为了与其他对象管理框架集成,这些框架希望完全修改 ORM 的检测方法,并且不打算定期使用。有关类检测事件的拦截,请参阅InstrumentationEvents
。
成员
dict_getter(), get_instance_dict(), initialize_instance_dict(), install_descriptor(), install_member(), install_state(), instrument_attribute(), instrument_collection_class(), 管理(), manager_getter(), post_configure_attribute(), remove_state()、state_getter()、uninstall_descriptor()、uninstall_member()、unregister()
此类的 API 应被视为半稳定 API,并且可能会随着新版本的发布而略有变化。-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
dict_getter(class_)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
get_instance_dict(class_, instance)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
initialize_instance_dict(class_, instance)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
install_descriptor(class_, key, inst)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
install_member(class_, key, implementation)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
install_state(class_, instance, state)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
instrument_attribute(class_, key, inst)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
instrument_collection_class(class_, key, collection_class)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
manage(class_, manager)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
manager_getter(class_)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
post_configure_attribute(class_, key, inst)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
remove_state(class_, instance)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
state_getter(class_)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
uninstall_descriptor(class_, key)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
uninstall_member(class_, key)¶
-
方法sqlalchemy.ext.instrumentation.InstrumentationManager.
unregister(class_, manager)¶
-
-
sqlalchemy.ext.instrumentation 的 instrumentation_finders = [<函数 find_native_user_instrumentation_hook>]¶
返回插桩实现的可扩展可调用对象序列
当一个类被注册时,每个可调用对象将被传递一个类对象。如果返回 None ,则查询序列中的下一个查找器。否则,返回值必须是遵循与 sqlalchemy.ext.instrumentation.INSTRUMENTATION_MANAGER 相同准则的检测工厂。
默认情况下,唯一的查找器是 find_native_user_instrumentation_hook,它搜索 INSTRUMENTATION_MANAGER。如果所有查找器都返回 None,则使用标准 ClassManager 插桩。
-
类 sqlalchemy.ext.instrumentation 中。ExtendedInstrumentationRegistry(扩展检测注册表)¶
通过额外的bookkeeping扩展 InstrumentationFactory
,以适应多种类型的类 Management 器。