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


Python hybrid.Comparator方法代码示例

本文整理汇总了Python中sqlalchemy.ext.hybrid.Comparator方法的典型用法代码示例。如果您正苦于以下问题:Python hybrid.Comparator方法的具体用法?Python hybrid.Comparator怎么用?Python hybrid.Comparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.ext.hybrid的用法示例。


在下文中一共展示了hybrid.Comparator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: comparator

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def comparator(self, comparator):
        """Provide a modifying decorator that defines a custom
        comparator producing method.

        The return value of the decorated method should be an instance of
        :class:`~.hybrid.Comparator`.

        """

        proxy_attr = attributes.\
            create_proxied_attribute(self)

        def expr(owner):
            return proxy_attr(owner, self.__name__, self, comparator(owner))
        self.expr = expr
        return self 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:hybrid.py

示例2: comparator

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def comparator(self, comparator):
        """Provide a modifying decorator that defines a custom
        comparator producing method.

        The return value of the decorated method should be an instance of
        :class:`~.hybrid.Comparator`.

        """

        proxy_attr = attributes.\
            create_proxied_attribute(self)

        def expr(owner):
            return proxy_attr(
                owner, self.__name__, self, comparator(owner),
                doc=comparator.__doc__ or self.__doc__)
        self.expr = expr
        return self 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:20,代码来源:hybrid.py

示例3: comparator

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def comparator(self, comparator):
        """Provide a modifying decorator that defines a custom
        comparator producing method.

        The return value of the decorated method should be an instance of
        :class:`~.hybrid.Comparator`.

        """

        proxy_attr = attributes.\
                        create_proxied_attribute(self)

        def expr(owner):
            return proxy_attr(owner, self.__name__, self, comparator(owner))
        self.expr = expr
        return self 
开发者ID:binhex,项目名称:moviegrabber,代码行数:18,代码来源:hybrid.py

示例4: comparator

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def comparator(self, comparator):
        """Provide a modifying decorator that defines a custom
        comparator producing method.

        The return value of the decorated method should be an instance of
        :class:`~.hybrid.Comparator`.

        .. note::  The :meth:`.hybrid_property.comparator` decorator
           **replaces** the use of the :meth:`.hybrid_property.expression`
           decorator.  They cannot be used together.

        When a hybrid is invoked at the class level, the
        :class:`~.hybrid.Comparator` object given here is wrapped inside of a
        specialized :class:`.QueryableAttribute`, which is the same kind of
        object used by the ORM to represent other mapped attributes.   The
        reason for this is so that other class-level attributes such as
        docstrings and a reference to the hybrid itself may be maintained
        within the structure that's returned, without any modifications to the
        original comparator object passed in.

        .. note::

           when referring to a hybrid property  from an owning class (e.g.
           ``SomeClass.some_hybrid``), an instance of
           :class:`.QueryableAttribute` is returned, representing the
           expression or comparator object as this  hybrid object.  However,
           that object itself has accessors called ``expression`` and
           ``comparator``; so when attempting to override these decorators on a
           subclass, it may be necessary to qualify it using the
           :attr:`.hybrid_property.overrides` modifier first.  See that
           modifier for details.

        """
        return self._copy(custom_comparator=comparator) 
开发者ID:yfauser,项目名称:planespotter,代码行数:36,代码来源:hybrid.py

示例5: comparator

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def comparator(self, comparator):
        """Provide a modifying decorator that defines a custom
        comparator producing method.

        The return value of the decorated method should be an instance of
        :class:`~.hybrid.Comparator`.

        .. note::  The :meth:`.hybrid_property.comparator` decorator
           **replaces** the use of the :meth:`.hybrid_property.expression`
           decorator.  They cannot be used together.

        When a hybrid is invoked at the class level, the
        :class:`~.hybrid.Comparator` object given here is wrapped inside of a
        specialized :class:`.QueryableAttribute`, which is the same kind of
        object used by the ORM to represent other mapped attributes.   The
        reason for this is so that other class-level attributes such as
        docstrings and a reference to the hybrid itself may be maintained
        within the structure that's returned, without any modifications to the
        original comparator object passed in.

        .. note::

           When referring to a hybrid property  from an owning class (e.g.
           ``SomeClass.some_hybrid``), an instance of
           :class:`.QueryableAttribute` is returned, representing the
           expression or comparator object as this  hybrid object.  However,
           that object itself has accessors called ``expression`` and
           ``comparator``; so when attempting to override these decorators on a
           subclass, it may be necessary to qualify it using the
           :attr:`.hybrid_property.overrides` modifier first.  See that
           modifier for details.

        """
        return self._copy(custom_comparator=comparator) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:36,代码来源:hybrid.py

示例6: _fixture

# 需要导入模块: from sqlalchemy.ext import hybrid [as 别名]
# 或者: from sqlalchemy.ext.hybrid import Comparator [as 别名]
def _fixture(self):
        Base = declarative_base()

        class UCComparator(hybrid.Comparator):
            def __eq__(self, other):
                if other is None:
                    return self.expression is None
                else:
                    return func.upper(self.expression) == func.upper(other)

        class A(Base):
            __tablename__ = "a"
            id = Column(Integer, primary_key=True)

            _value = Column("value", String)

            @hybrid.hybrid_property
            def value(self):
                "This is a docstring"
                return self._value - 5

            @value.comparator
            def value(cls):
                return UCComparator(cls._value)

            @value.setter
            def value(self, v):
                self._value = v + 5

        return A 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:32,代码来源:test_hybrid.py


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