def search(self, q, mode, types, level, limit, offset): level = AccessType.validate(level) user = self.getCurrentUser() if mode == 'text': method = 'textSearch' else: method = 'prefixSearch' results = {} for modelName in types: if modelName not in allowedSearchTypes: continue if '.' in modelName: name, plugin = modelName.rsplit('.', 1) model = self.model(name, plugin) else: model = self.model(modelName) results[modelName] = [ model.filter(d, user) for d in getattr(model, method) (query=q, user=user, limit=limit, offset=offset, level=level) ] return results
def search(self, q, mode, types, level, limit, offset, params): level = AccessType.validate(level) user = self.getCurrentUser() if mode == 'text': method = 'textSearch' else: method = 'prefixSearch' results = {} for modelName in types: if modelName not in allowedSearchTypes: continue if '.' in modelName: name, plugin = modelName.rsplit('.', 1) model = self.model(name, plugin) else: model = self.model(modelName) results[modelName] = [ model.filter(d, user) for d in getattr(model, method)( query=q, user=user, limit=limit, offset=offset, level=level) ] return results
def search(self, q, mode, types, level, limit, offset): """ Perform a search using one of the registered search modes. """ level = AccessType.validate(level) user = self.getCurrentUser() handler = getSearchModeHandler(mode) if handler is None: raise RestException('Search mode handler %r not found.' % mode) results = handler(query=q, types=types, user=user, limit=limit, offset=offset, level=level) return results
def search(self, q, mode, types, level, limit, offset): """ Perform a search using one of the registered search modes. """ level = AccessType.validate(level) user = self.getCurrentUser() handler = getSearchModeHandler(mode) if handler is None: raise RestException('Search mode handler %r not found.' % mode) results = handler( query=q, types=types, user=user, limit=limit, offset=offset, level=level ) return results
def search(self, params): self.requireParams(('q', 'types'), params) mode = params.get('mode', 'text') level = AccessType.validate(params.get('level', AccessType.READ)) user = self.getCurrentUser() limit = int(params.get('limit', 10)) offset = int(params.get('offset', 0)) if mode == 'text': method = 'textSearch' elif mode == 'prefix': method = 'prefixSearch' else: raise RestException( 'The search mode must be either "text" or "prefix".') try: types = json.loads(params['types']) except ValueError: raise RestException('The types parameter must be JSON.') results = {} for modelName in types: if modelName not in allowedSearchTypes: continue if '.' in modelName: name, plugin = modelName.rsplit('.', 1) model = self.model(name, plugin) else: model = self.model(modelName) results[modelName] = [ model.filter(d, user) for d in getattr(model, method)(query=params['q'], user=user, limit=limit, offset=offset, level=level) ] return results
def search(self, params): self.requireParams(('q', 'types'), params) mode = params.get('mode', 'text') level = AccessType.validate(params.get('level', AccessType.READ)) user = self.getCurrentUser() limit = int(params.get('limit', 10)) offset = int(params.get('offset', 0)) if mode == 'text': method = 'textSearch' elif mode == 'prefix': method = 'prefixSearch' else: raise RestException( 'The search mode must be either "text" or "prefix".') try: types = json.loads(params['types']) except ValueError: raise RestException('The types parameter must be JSON.') results = {} for modelName in types: if modelName not in allowedSearchTypes: continue if '.' in modelName: name, plugin = modelName.rsplit('.', 1) model = self.model(name, plugin) else: model = self.model(modelName) results[modelName] = [ model.filter(d, user) for d in getattr(model, method)( query=params['q'], user=user, limit=limit, offset=offset, level=level) ] return results