當前位置: 首頁>>代碼示例>>Python>>正文


Python mutable.MutableComposite方法代碼示例

本文整理匯總了Python中sqlalchemy.ext.mutable.MutableComposite方法的典型用法代碼示例。如果您正苦於以下問題:Python mutable.MutableComposite方法的具體用法?Python mutable.MutableComposite怎麽用?Python mutable.MutableComposite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.ext.mutable的用法示例。


在下文中一共展示了mutable.MutableComposite方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_listen_keys

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def _get_listen_keys(cls, attribute):
        """Given a descriptor attribute, return a ``set()`` of the attribute
        keys which indicate a change in the state of this attribute.

        This is normally just ``set([attribute.key])``, but can be overridden
        to provide for additional keys.  E.g. a :class:`.MutableComposite`
        augments this set with the attribute keys associated with the columns
        that comprise the composite value.

        This collection is consulted in the case of intercepting the
        :meth:`.InstanceEvents.refresh` and
        :meth:`.InstanceEvents.refresh_flush` events, which pass along a list
        of attribute names that have been refreshed; the list is compared
        against this set to determine if action needs to be taken.

        .. versionadded:: 1.0.5

        """
        return set([attribute.key]) 
開發者ID:jpush,項目名稱:jbox,代碼行數:21,代碼來源:mutable.py

示例2: _get_listen_keys

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def _get_listen_keys(cls, attribute):
        """Given a descriptor attribute, return a ``set()`` of the attribute
        keys which indicate a change in the state of this attribute.

        This is normally just ``set([attribute.key])``, but can be overridden
        to provide for additional keys.  E.g. a :class:`.MutableComposite`
        augments this set with the attribute keys associated with the columns
        that comprise the composite value.

        This collection is consulted in the case of intercepting the
        :meth:`.InstanceEvents.refresh` and
        :meth:`.InstanceEvents.refresh_flush` events, which pass along a list
        of attribute names that have been refreshed; the list is compared
        against this set to determine if action needs to be taken.

        .. versionadded:: 1.0.5

        """
        return {attribute.key} 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:21,代碼來源:mutable.py

示例3: coerce

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def coerce(cls, key, value):
        """Given a value, coerce it into the target type.

        Can be overridden by custom subclasses to coerce incoming
        data into a particular type.

        By default, raises ``ValueError``.

        This method is called in different scenarios depending on if
        the parent class is of type :class:`.Mutable` or of type
        :class:`.MutableComposite`.  In the case of the former, it is called
        for both attribute-set operations as well as during ORM loading
        operations.  For the latter, it is only called during attribute-set
        operations; the mechanics of the :func:`.composite` construct
        handle coercion during load operations.


        :param key: string name of the ORM-mapped attribute being set.
        :param value: the incoming value.
        :return: the method should return the coerced value, or raise
         ``ValueError`` if the coercion cannot be completed.

        """
        if value is None:
            return None
        msg = "Attribute '%s' does not accept objects of type %s"
        raise ValueError(msg % (key, type(value))) 
開發者ID:jpush,項目名稱:jbox,代碼行數:29,代碼來源:mutable.py

示例4: _setup_composite_listener

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def _setup_composite_listener():
    def _listen_for_type(mapper, class_):
        for prop in mapper.iterate_properties:
            if (hasattr(prop, 'composite_class') and
                    isinstance(prop.composite_class, type) and
                    issubclass(prop.composite_class, MutableComposite)):
                prop.composite_class._listen_on_attribute(
                    getattr(class_, prop.key), False, class_)
    if not event.contains(Mapper, "mapper_configured", _listen_for_type):
        event.listen(Mapper, 'mapper_configured', _listen_for_type) 
開發者ID:jpush,項目名稱:jbox,代碼行數:12,代碼來源:mutable.py

示例5: _setup_composite_listener

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def _setup_composite_listener():
    def _listen_for_type(mapper, class_):
        for prop in mapper.iterate_properties:
            if (
                hasattr(prop, "composite_class")
                and isinstance(prop.composite_class, type)
                and issubclass(prop.composite_class, MutableComposite)
            ):
                prop.composite_class._listen_on_attribute(
                    getattr(class_, prop.key), False, class_
                )

    if not event.contains(Mapper, "mapper_configured", _listen_for_type):
        event.listen(Mapper, "mapper_configured", _listen_for_type) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:mutable.py

示例6: setup_mappers

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def setup_mappers(cls):
        foo = cls.tables.foo

        Point = cls._type_fixture()

        # in this case, this is not actually a MutableComposite.
        # so we don't expect it to track changes
        mapper(
            Foo,
            foo,
            properties={
                "data": composite(lambda x, y: Point(x, y), foo.c.x, foo.c.y)
            },
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:test_mutable.py

示例7: _setup_composite_listener

# 需要導入模塊: from sqlalchemy.ext import mutable [as 別名]
# 或者: from sqlalchemy.ext.mutable import MutableComposite [as 別名]
def _setup_composite_listener():
    def _listen_for_type(mapper, class_):
        for prop in mapper.iterate_properties:
            if (hasattr(prop, 'composite_class') and
                isinstance(prop.composite_class, type) and
                 issubclass(prop.composite_class, MutableComposite)):
                prop.composite_class._listen_on_attribute(
                    getattr(class_, prop.key), False, class_)
    if not event.contains(Mapper, "mapper_configured", _listen_for_type):
        event.listen(Mapper, 'mapper_configured', _listen_for_type) 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:12,代碼來源:mutable.py


注:本文中的sqlalchemy.ext.mutable.MutableComposite方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。