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)
评论列表
文章目录