當前位置: 首頁>>代碼示例>>Python>>正文


Python Request.populate方法代碼示例

本文整理匯總了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)
開發者ID:kcmoffat,項目名稱:bumpn-backend,代碼行數:33,代碼來源:views.py


注:本文中的models.Request.populate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。