示例#1
0
文件: xhr.py 项目: fredsod/NIPAP
    def smart_search_pool(self):
        """ Perform a smart pool search.

            The "smart" search function tries extract a query from
            a text string. This query is then passed to the search_pool
            function, which performs the search.
        """

        search_options = {}

        if 'query_id' in request.json:
            search_options['query_id'] = request.json['query_id']

        if 'max_result' in request.json:
            search_options['max_result'] = request.json['max_result']
        if 'offset' in request.json:
            search_options['offset'] = request.json['offset']

        try:
            result = Pool.smart_search(request.json['query_string'],
                search_options
                )
            # Remove error key in result from backend as it interferes with the
            # error handling of the web interface.
            # TODO: Reevaluate how to deal with different types of errors; soft
            # errors like query string parser errors and hard errors like lost
            # database.
            del result['error']
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例#2
0
    def smart_search_pool(self):
        """ Perform a smart pool search.

            The "smart" search function tries extract a query from
            a text string. This query is then passed to the search_pool
            function, which performs the search.
        """

        search_options = {}

        if 'query_id' in request.json:
            search_options['query_id'] = request.json['query_id']

        if 'max_result' in request.json:
            search_options['max_result'] = request.json['max_result']
        if 'offset' in request.json:
            search_options['offset'] = request.json['offset']

        try:
            result = Pool.smart_search(request.json['query_string'],
                                       search_options)
            # Remove error key in result from backend as it interferes with the
            # error handling of the web interface.
            # TODO: Reevaluate how to deal with different types of errors; soft
            # errors like query string parser errors and hard errors like lost
            # database.
            del result['error']
        except NipapError, e:
            return json.dumps({
                'error': 1,
                'message': e.args,
                'type': type(e).__name__
            })
示例#3
0
    def smart_search_pool(self):
        """ Perform a smart pool search.

            The "smart" search function tries extract a query from
            a text string. This query is then passed to the search_pool
            function, which performs the search.
        """

        search_options = {}

        if 'query_id' in request.params:
            search_options['query_id'] = request.params['query_id']

        if 'max_result' in request.params:
            search_options['max_result'] = request.params['max_result']
        if 'offset' in request.params:
            search_options['offset'] = request.params['offset']

        try:
            result = Pool.smart_search(request.params['query_string'],
                                       search_options)
        except NipapError, e:
            return json.dumps({
                'error': 1,
                'message': e.args,
                'type': type(e).__name__
            })
示例#4
0
文件: xhr.py 项目: tobbakko/NIPAP
    def smart_search_pool(self):
        """ Perform a smart pool search.

            The "smart" search function tries extract a query from
            a text string. This query is then passed to the search_pool
            function, which performs the search.
        """

        search_options = {}

        if 'query_id' in request.params:
            search_options['query_id'] = request.params['query_id']

        if 'max_result' in request.params:
            search_options['max_result'] = request.params['max_result']
        if 'offset' in request.params:
            search_options['offset'] = request.params['offset']

        log.debug("params: %s" % str(request.params))

        log.debug("Smart search query: schema=%d q=%s search_options=%s" %
            (int(request.params['schema']),
            request.params['query_string'],
            str(search_options)
        ))

        try:
            schema = Schema.get(int(request.params['schema']))
            result = Pool.smart_search(schema,
                request.params['query_string'],
                search_options
                )
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例#5
0
文件: xhr.py 项目: AlfredArouna/NIPAP
    def smart_search_pool(self):
        """ Perform a smart pool search.

            The "smart" search function tries extract a query from
            a text string. This query is then passed to the search_pool
            function, which performs the search.
        """

        search_options = {}

        if 'query_id' in request.params:
            search_options['query_id'] = request.params['query_id']

        if 'max_result' in request.params:
            search_options['max_result'] = request.params['max_result']
        if 'offset' in request.params:
            search_options['offset'] = request.params['offset']

        try:
            result = Pool.smart_search(request.params['query_string'],
                search_options
                )
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例#6
0
 def test_smart_search_pool(self):
     """ We should be able to execute smart_search_pool as read-only user
     """
     p = Pool.smart_search('default')