本文整理汇总了Python中models.Request.put方法的典型用法代码示例。如果您正苦于以下问题:Python Request.put方法的具体用法?Python Request.put怎么用?Python Request.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Request
的用法示例。
在下文中一共展示了Request.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import put [as 别名]
def post(self):
user = self.user_model
location = cgi.escape(self.request.get("location")).strip().lower()
date = cgi.escape(self.request.get("date"))
r_time = cgi.escape(self.request.get("time"))
price = int(cgi.escape(self.request.get("price")))
food_type = cgi.escape(self.request.get("food_type")).strip().lower()
interest = cgi.escape(self.request.get("interest")).strip().lower()
# Convert date and time to datetime
format_date = str(date+ " " +r_time+":00.0")
start_time = datetime.datetime.strptime(format_date, "%Y-%m-%d %H:%M:%S.%f")
# Create request
request = Request()
request.sender = user.key
request.sender_name = user.username
request.location = location
request.start_time = start_time
request.creation_time = datetime.datetime.now() - datetime.timedelta(hours=8) #PST
request.price = abs(price)
request.food_type = food_type
request.interest = interest
request.status = "waiting for a bid"
request.put()
print "Added request to queue"
time.sleep(1)
self.redirect('/')
示例2: requestsv2
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import put [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)