def __init__( self, request, separate_replies=False, separate_wildcard_uri_keys=True, _replies_limit=200, ): self.es = request.es self.separate_replies = separate_replies self._replies_limit = _replies_limit # Order matters! The KeyValueMatcher must be run last, # after all other modifiers have popped off the params. self._modifiers = [ query.Sorter(), query.Limiter(), query.DeletedFilter(), query.AuthFilter(request), query.GroupFilter(), query.GroupAuthFilter(request), query.UserFilter(), query.HiddenFilter(request), query.AnyMatcher(), query.TagsMatcher(), query.UriCombinedWildcardFilter( request, separate_keys=separate_wildcard_uri_keys ), query.KeyValueMatcher(), ] self._aggregations = []
def __init__(self, request, separate_replies=False, stats=None, _replies_limit=200): self.es = request.es self.separate_replies = separate_replies self.stats = stats self._replies_limit = _replies_limit # Order matters! The KeyValueMatcher must be run last, # after all other modifiers have popped off the params. self._modifiers = [ query.Sorter(), query.Limiter(), query.DeletedFilter(), query.AuthFilter(request), query.GroupFilter(), query.GroupAuthFilter(request), query.UserFilter(), query.NipsaFilter(request), query.AnyMatcher(), query.TagsMatcher(), query.KeyValueMatcher() ] self._aggregations = []
def test_authenticated(self): request = mock.Mock(authenticated_userid='acct:[email protected]') authfilter = query.AuthFilter(request) assert authfilter({}) == { 'or': [ {'term': {'shared': True}}, {'term': {'user_raw': 'acct:[email protected]'}}, ] }
def _default_querybuilder(request, es): builder = query.Builder(es_version=es.version) builder.append_filter(query.DeletedFilter()) builder.append_filter(query.AuthFilter(request)) builder.append_filter(query.UriFilter(request)) builder.append_filter(query.GroupFilter()) builder.append_filter(query.GroupAuthFilter(request)) builder.append_filter(query.UserFilter()) builder.append_filter(query.NipsaFilter(request)) builder.append_matcher(query.AnyMatcher()) builder.append_matcher(query.TagsMatcher()) return builder
def default_querybuilder(request): builder = query.Builder() builder.append_filter(query.DeletedFilter()) builder.append_filter(query.AuthFilter(request)) builder.append_filter(query.UriFilter(request)) builder.append_filter(query.GroupFilter()) builder.append_filter(query.UserFilter()) builder.append_matcher(query.AnyMatcher()) builder.append_matcher(query.TagsMatcher()) for factory in request.registry.get(FILTERS_KEY, []): builder.append_filter(factory(request)) return builder
def search(self, search, pyramid_request): search.append_modifier(query.AuthFilter(pyramid_request)) return search
def test_unauthenticated(self): request = mock.Mock(authenticated_userid=None) authfilter = query.AuthFilter(request) assert authfilter({}) == {'term': {'shared': True}}