model_base.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:flask-gae-ndb-starter 作者: jideobs 项目源码 文件源码
def _AddFilter(self, candidate_filter):
        """Checks a filter and sets it in the filter set.

Args:
  candidate_filter: An NDB filter which may be added to the query info.

Raises:
  AttributeError: if query on the object is already final.
  TypeError: if the filter is not a simple filter (FilterNode).
  ValueError: if the operator symbol in the filter is not equality.
"""
        if self._query_final is not None:
            raise AttributeError('Can\'t add more filters. Query info is final.')

        if not isinstance(candidate_filter, ndb.FilterNode):
            raise TypeError('Only simple filters can be used. Received: %s.' %
                            (candidate_filter,))
        opsymbol = candidate_filter._FilterNode__opsymbol
        if opsymbol != '=':
            raise ValueError('Only equality filters allowed. Received: %s.' %
                             (opsymbol,))

        self._filters.add(candidate_filter)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号