本文整理汇总了Python中webargs.core.get_value函数的典型用法代码示例。如果您正苦于以下问题:Python get_value函数的具体用法?Python get_value怎么用?Python get_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_form
def parse_form(self, req, name, field):
"""Pull a form value from the request."""
post_data = self._cache.get('post')
if post_data is None:
yield from req.post()
self._cache['post'] = req.POST
return core.get_value(self._cache['post'], name, field)
示例2: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request."""
try:
json_data = webapp2_extras.json.decode(req.body)
return core.get_value(json_data, name, arg.multiple)
except ValueError:
return core.Missing
示例3: parse_form
def parse_form(self, req, name, field):
"""Pull a form value from the request."""
try:
return core.get_value(req.form, name, field)
except AttributeError:
pass
return core.missing
示例4: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request."""
try:
return core.get_value(req.json, name, arg.multiple)
except (AttributeError, ValueError):
pass
return core.Missing
示例5: parse_form
def parse_form(self, req, name, arg):
"""Pull a form value from the request."""
try:
return core.get_value(req.form, name, arg.multiple)
except AttributeError:
pass
return core.Missing
示例6: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request body."""
try:
reqdata = json.loads(req.body.decode('utf-8'))
return core.get_value(reqdata, name, arg.multiple)
except (AttributeError, ValueError):
return None
示例7: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request."""
# Fail silently so that the webargs parser can handle the error
json_data = req.get_json(silent=True)
if json_data:
return core.get_value(json_data, name, arg.multiple)
else:
return core.Missing
示例8: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request."""
try:
json_data = req.json_body
except ValueError:
return core.Missing
return core.get_value(json_data, name, arg.multiple)
示例9: parse_json
def parse_json(self, req, name, field):
"""Pull a json value from the request body."""
try:
reqdata = json.loads(req.body.decode('utf-8'))
return core.get_value(reqdata, name, field)
except (AttributeError, ValueError):
pass
return core.missing
示例10: parse_json
def parse_json(self, req, name, arg):
"""Pull a json value from the request."""
if req.content_type == 'application/json' and hasattr(req, 'json'):
try:
return core.get_value(req.json, name, arg.multiple)
except AttributeError:
return None
else:
return None
示例11: parse_json
def parse_json(self, req, name, field):
"""Pull a json value from the request."""
if req.has_body:
json_data = self._cache.get('json')
if json_data is None:
self._cache['json'] = yield from req.json()
return core.get_value(self._cache['json'], name, field)
else:
return core.missing
示例12: parse_json
def parse_json(self, req, name, field):
"""Pull a json value from the request."""
json_body = self._cache.get('json')
if json_body is None:
try:
self._cache['json'] = json_body = req.json
except (AttributeError, ValueError):
return core.missing
if json_body is not None:
return core.get_value(req.json, name, field)
else:
return core.missing
示例13: parse_json
def parse_json(self, req, name, field):
"""Pull a json value from the request."""
# Pass force in order to handle vendor media types,
# e.g. applications/vnd.json+api
# this should be unnecessary in Flask 1.0
force = is_json_request(req)
# Fail silently so that the webargs parser can handle the error
json_data = req.get_json(force=force, silent=True)
if json_data:
return core.get_value(json_data, name, field)
else:
return core.missing
示例14: parse_matchdict
def parse_matchdict(self, req, name, field):
"""Pull a value from the request's `matchdict`."""
return core.get_value(req.matchdict, name, field)
示例15: parse_cookies
def parse_cookies(self, req, name, arg):
"""Pull the value from the cookiejar."""
return core.get_value(req.cookies, name, arg.multiple)