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


Python Request.to_dict方法代码示例

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


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

示例1: requestsv2

# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import to_dict [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)
开发者ID:kcmoffat,项目名称:bumpn-backend,代码行数:33,代码来源:views.py


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