本文整理汇总了Python中sqlalchemy.orm.collections.collection._sa_adapter方法的典型用法代码示例。如果您正苦于以下问题:Python collection._sa_adapter方法的具体用法?Python collection._sa_adapter怎么用?Python collection._sa_adapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.orm.collections.collection
的用法示例。
在下文中一共展示了collection._sa_adapter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: linker
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def linker(fn):
"""Tag the method as a "linked to attribute" event handler.
This optional event handler will be called when the collection class
is linked to or unlinked from the InstrumentedAttribute. It is
invoked immediately after the '_sa_adapter' property is set on
the instance. A single argument is passed: the collection adapter
that has been linked, or None if unlinking.
.. deprecated:: 1.0.0 - the :meth:`.collection.linker` handler
is superseded by the :meth:`.AttributeEvents.init_collection`
and :meth:`.AttributeEvents.dispose_collection` handlers.
"""
fn._sa_instrument_role = 'linker'
return fn
示例2: _set_collection_attributes
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def _set_collection_attributes(cls, roles, methods):
"""apply ad-hoc instrumentation from decorators, class-level defaults
and implicit role declarations
"""
for method_name, (before, argument, after) in methods.items():
setattr(cls, method_name,
_instrument_membership_mutator(getattr(cls, method_name),
before, argument, after))
# intern the role map
for role, method_name in roles.items():
setattr(cls, '_sa_%s' % role, getattr(cls, method_name))
cls._sa_adapter = None
if not hasattr(cls, '_sa_converter'):
cls._sa_converter = None
cls._sa_instrumented = id(cls)
示例3: _set_collection_attributes
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def _set_collection_attributes(cls, roles, methods):
"""apply ad-hoc instrumentation from decorators, class-level defaults
and implicit role declarations
"""
for method_name, (before, argument, after) in methods.items():
setattr(
cls,
method_name,
_instrument_membership_mutator(
getattr(cls, method_name), before, argument, after
),
)
# intern the role map
for role, method_name in roles.items():
setattr(cls, "_sa_%s" % role, getattr(cls, method_name))
cls._sa_adapter = None
if not hasattr(cls, "_sa_converter"):
cls._sa_converter = None
cls._sa_instrumented = id(cls)
示例4: __init__
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def __init__(self, attr, owner_state, data):
self._key = attr.key
self._data = weakref.ref(data)
self.owner_state = owner_state
data._sa_adapter = self
示例5: __del
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def __del(collection, item, _sa_initiator=None):
"""Run del events, may eventually be inlined into decorators."""
if _sa_initiator is not False:
executor = collection._sa_adapter
if executor:
executor.fire_remove_event(item, _sa_initiator)
示例6: __before_delete
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def __before_delete(collection, _sa_initiator=None):
"""Special method to run 'commit existing value' methods"""
executor = collection._sa_adapter
if executor:
executor.fire_pre_remove_event(_sa_initiator)
示例7: __init__
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def __init__(self, attr, owner_state, data):
self.attr = attr
self._key = attr.key
self._data = weakref.ref(data)
self.owner_state = owner_state
data._sa_adapter = self
self._converter = data._sa_converter
self.invalidated = False
示例8: __setstate__
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def __setstate__(self, d):
self._key = d['key']
self.owner_state = d['owner_state']
self._data = weakref.ref(d['data'])
self._converter = d['data']._sa_converter
d['data']._sa_adapter = self
self.invalidated = d['invalidated']
self.attr = getattr(d['owner_cls'], self._key).impl
示例9: linker
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def linker(fn):
"""Tag the method as a "linked to attribute" event handler.
This optional event handler will be called when the collection class
is linked to or unlinked from the InstrumentedAttribute. It is
invoked immediately after the '_sa_adapter' property is set on
the instance. A single argument is passed: the collection adapter
that has been linked, or None if unlinking.
"""
fn._sa_instrument_role = 'linker'
return fn
示例10: link_to_self
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def link_to_self(self, data):
"""Link a collection to this adapter"""
data._sa_adapter = self
if data._sa_linker:
data._sa_linker(self)
示例11: unlink
# 需要导入模块: from sqlalchemy.orm.collections import collection [as 别名]
# 或者: from sqlalchemy.orm.collections.collection import _sa_adapter [as 别名]
def unlink(self, data):
"""Unlink a collection from any adapter"""
del data._sa_adapter
if data._sa_linker:
data._sa_linker(None)