本文整理汇总了Python中models.Request.populate方法的典型用法代码示例。如果您正苦于以下问题:Python Request.populate方法的具体用法?Python Request.populate怎么用?Python Request.populate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Request
的用法示例。
在下文中一共展示了Request.populate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: requestsv2
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import populate [as 别名]
def requestsv2():
if not request.args or not request.args['key'] or request.args['key'] != IOS_API_KEY:
abort(401)
if request.method == "POST":
if not request.json or not 'google_places_id' in request.json or not 'name' in request.json or not 'vicinity' in request.json:
abort(400)
report_request = Request(google_places_id=request.json['google_places_id'],
name=request.json['name'],
vicinity=request.json['vicinity'])
questions = ''
more_questions = ''
if 'ios_device_id' in request.json:
report_request.populate(ios_device_id=request.json['ios_device_id'])
if 'questions' in request.json:
report_request.populate(questions=request.json['questions'])
questions = request.json['questions']
if 'more_questions' in request.json:
report_request.populate(more_questions=request.json['more_questions'])
more_questions = request.json['more_questions']
try:
report_request.put()
sender_address = "Scout Support <[email protected]>"
user_address = "[email protected]"
subject = "Update requested at %s" % request.json['name']
body = """Name: %s\nAddress: %s\nQuestions: %s\nMore Questions: %s""" % (request.json['name'], request.json['vicinity'], ', '.join(questions), more_questions)
logging.info('questions: %s', ', '.join(questions))
logging.info('more_questions: %s', more_questions)
mail.send_mail(sender_address, user_address, subject, body)
return jsonify(report_request.to_dict())
except CapabilityDisabledError:
abort(400)