当前位置: 首页>>代码示例>>Python>>正文


Python collection._sa_adapter方法代码示例

本文整理汇总了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 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:collections.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:collections.py

示例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) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:24,代码来源:collections.py

示例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 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:collections.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:collections.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:collections.py

示例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 
开发者ID:yfauser,项目名称:planespotter,代码行数:10,代码来源:collections.py

示例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 
开发者ID:yfauser,项目名称:planespotter,代码行数:10,代码来源:collections.py

示例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 
开发者ID:gltn,项目名称:stdm,代码行数:14,代码来源:collections.py

示例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) 
开发者ID:gltn,项目名称:stdm,代码行数:8,代码来源:collections.py

示例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) 
开发者ID:gltn,项目名称:stdm,代码行数:8,代码来源:collections.py


注:本文中的sqlalchemy.orm.collections.collection._sa_adapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。