当前位置: 首页>>代码示例>>Python>>正文


Python VRF.smart_search方法代码示例

本文整理汇总了Python中pynipap.VRF.smart_search方法的典型用法代码示例。如果您正苦于以下问题:Python VRF.smart_search方法的具体用法?Python VRF.smart_search怎么用?Python VRF.smart_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynipap.VRF的用法示例。


在下文中一共展示了VRF.smart_search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: smart_search_vrf

# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import smart_search [as 别名]
    def smart_search_vrf(self):
        """ Perform a smart VRF search.

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

        search_options = {}
        extra_query = None

        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']

        if 'vrf_id' in request.params:
            extra_query = {
                    'val1': 'id',
                    'operator': 'equals',
                    'val2': request.params['vrf_id']
                }

        try:
            result = VRF.smart_search(request.params['query_string'],
                search_options, extra_query
                )
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:AlfredArouna,项目名称:NIPAP,代码行数:35,代码来源:xhr.py

示例2: smart_search_vrf

# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import smart_search [as 别名]
    def smart_search_vrf(self):
        """ Perform a smart VRF search.

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

        search_options = {}
        extra_query = None

        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']

        if 'vrf_id' in request.json:
            extra_query = {
                    'val1': 'id',
                    'operator': 'equals',
                    'val2': request.json['vrf_id']
                }

        try:
            result = VRF.smart_search(request.json['query_string'],
                search_options, extra_query
                )
            # 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__})
开发者ID:fredsod,项目名称:NIPAP,代码行数:41,代码来源:xhr.py

示例3: test_smart_search_vrf

# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import smart_search [as 别名]
 def test_smart_search_vrf(self):
     """ We should be able to execute smart_search_vrf as read-only user
     """
     v = VRF.smart_search('default')
     self.assertEqual(v['result'][0].id, 0)
开发者ID:AlfredArouna,项目名称:NIPAP,代码行数:7,代码来源:nipap-ro.py


注:本文中的pynipap.VRF.smart_search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。