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


Python reqparse.RequestParser方法代码示例

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


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

示例1: as_request_parser

# 需要导入模块: from flask_restplus import reqparse [as 别名]
# 或者: from flask_restplus.reqparse import RequestParser [as 别名]
def as_request_parser(cls, paginate=True):
        parser = RequestParser()
        # q parameter
        parser.add_argument('q', type=str, location='args',
                            help='The search query')
        # Expected facets
        # (ie. I want all facets or I want both tags and licenses facets)
        facets = list(cls.facets)
        if facets:
            parser.add_argument('facets', type=str, location='args',
                                choices=['all'] + facets,
                                action='append',
                                help='Selected facets to fetch')
        # Add facets filters arguments
        # (apply a value to a facet ie. tag=value)
        for name, facet in cls.facets.items():
            kwargs = facet.as_request_parser_kwargs()
            parser.add_argument(name, location='args', **kwargs)
        # Sort arguments
        keys = list(cls.sorts)
        choices = keys + ['-' + k for k in keys]
        help_msg = 'The field (and direction) on which sorting apply'
        parser.add_argument('sort', type=str, location='args', choices=choices,
                            help=help_msg)
        if paginate:
            parser.add_argument('page', type=int, location='args',
                                default=0, help='The page to display')
            parser.add_argument('page_size', type=int, location='args',
                                default=20, help='The page size')
        return parser 
开发者ID:opendatateam,项目名称:udata,代码行数:32,代码来源:adapter.py

示例2: test_as_request_parser_terms_facet

# 需要导入模块: from flask_restplus import reqparse [as 别名]
# 或者: from flask_restplus.reqparse import RequestParser [as 别名]
def test_as_request_parser_terms_facet(self):
        parser = FakeSearch.as_request_parser()
        assert isinstance(parser, RequestParser)

        # query + facets selector + tag and other facets + sorts + pagination
        assert len(parser.args) == 7
        assertHasArgument(parser, 'q', str)
        assertHasArgument(parser, 'sort', str)
        assertHasArgument(parser, 'facets', str)
        assertHasArgument(parser, 'tag', clean_string)
        assertHasArgument(parser, 'other', clean_string)
        assertHasArgument(parser, 'page', int)
        assertHasArgument(parser, 'page_size', int) 
开发者ID:opendatateam,项目名称:udata,代码行数:15,代码来源:test_adapter.py

示例3: test_as_request_parser_bool_facet

# 需要导入模块: from flask_restplus import reqparse [as 别名]
# 或者: from flask_restplus.reqparse import RequestParser [as 别名]
def test_as_request_parser_bool_facet(self):
        parser = FakeSearchWithBool.as_request_parser()
        assert isinstance(parser, RequestParser)

        # query + facets selector + boolean facet + sorts + pagination
        assert len(parser.args) == 6
        assertHasArgument(parser, 'q', str)
        assertHasArgument(parser, 'sort', str)
        assertHasArgument(parser, 'facets', str)
        assertHasArgument(parser, 'boolean', inputs.boolean)
        assertHasArgument(parser, 'page', int)
        assertHasArgument(parser, 'page_size', int) 
开发者ID:opendatateam,项目名称:udata,代码行数:14,代码来源:test_adapter.py

示例4: test_as_request_parser_range_facet

# 需要导入模块: from flask_restplus import reqparse [as 别名]
# 或者: from flask_restplus.reqparse import RequestParser [as 别名]
def test_as_request_parser_range_facet(self):
        parser = FakeSearchWithRange.as_request_parser()
        facet = FakeSearchWithRange.facets['range']
        assert isinstance(parser, RequestParser)

        # query + facets selector + range facet + sorts + pagination
        assert len(parser.args) == 6
        assertHasArgument(parser, 'q', str)
        assertHasArgument(parser, 'sort', str)
        assertHasArgument(parser, 'facets', str)
        assertHasArgument(parser, 'range', facet.validate_parameter,
                          choices=RANGE_LABELS.keys())
        assertHasArgument(parser, 'page', int)
        assertHasArgument(parser, 'page_size', int) 
开发者ID:opendatateam,项目名称:udata,代码行数:16,代码来源:test_adapter.py

示例5: test_as_request_parser_temporal_coverage_facet

# 需要导入模块: from flask_restplus import reqparse [as 别名]
# 或者: from flask_restplus.reqparse import RequestParser [as 别名]
def test_as_request_parser_temporal_coverage_facet(self):
        parser = FakeSearchWithCoverage.as_request_parser()
        facet = FakeSearchWithCoverage.facets['coverage']
        assert isinstance(parser, RequestParser)

        # query + facets selector + range facet + sorts + pagination
        assert len(parser.args) == 6
        assertHasArgument(parser, 'q', str)
        assertHasArgument(parser, 'sort', str)
        assertHasArgument(parser, 'facets', str)
        assertHasArgument(parser, 'coverage', facet.validate_parameter)
        assertHasArgument(parser, 'page', int)
        assertHasArgument(parser, 'page_size', int) 
开发者ID:opendatateam,项目名称:udata,代码行数:15,代码来源:test_adapter.py


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