一个请求解析接口,用于提供对webapp2中webapp2.request对象上的任何变量的简单而统一的访问
webapp2_restful的Python项目详细描述
webapp2\u restful库是一个受restful-flask’s request parser启发的请求解析接口。
它的接口是根据argparse接口建模的。
它的目标是提供对webapp2.request对象上任何变量的统一访问,并允许处理程序在 指定他们希望调用的参数-使代码更易于阅读和理解。
- 免费软件:BSD许可证
- 文档:https://webapp2_restful.readthedocs.org。
基本参数分析
下面是请求解析器的一个简单示例。 它在webapp2.request的json和params属性中查找两个参数:一个是int类型,另一个是str:
from webapp2_restful.parser import RequestParser parser = RequestParser() parser.add_argument('rate', type=int, help='Rate cannot be converted') parser.add_argument('name', type=str) args = parser.parse_args(self.request)
特殊的google appengine参数
from webapp2_restful.parser import RequestParser from webapp2_restful.arguments_ndb import EntityIDArgument parser = RequestParser() parser.add_argument('store_id', type=EntityIDArgument(Store), dest='store') args = parser.parse_args(self.request) # args.store is a Store instance print(args.store)
历史记录
0.1.0(2015-01-11)
- pypi上的第一个版本。