當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。