本文整理汇总了Python中models.Order.key方法的典型用法代码示例。如果您正苦于以下问题:Python Order.key方法的具体用法?Python Order.key怎么用?Python Order.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import key [as 别名]
def post(self, **kwargs):
current_user = self.auth_current_user
products = self.get_cart_content()
items = []
if self.form.validate():
user = current_user
delivery_method = self.form.delivery_method.data
delivery_area = self.form.delivery_area.data
delivery_info = self.form.delivery_info.data
delivery_address = self.form.delivery_address.data
delivery_city = self.form.delivery_city.data
delivery_zip = self.form.delivery_zip.data
comment = self.form.comment.data
items = str(products)
order = Order(items=items, user=user.key(), delivery_method=delivery_method, delivery_address=delivery_address, delivery_city=delivery_city, delivery_zip=delivery_zip, comment=comment, delivery_info=delivery_info, delivery_area=delivery_area)
if order.put():
url = '/mail/notify/order/'
order_id = str(order.key().id())
payload = { 'order_id': order_id }
task = taskqueue.add(url=url, params=payload)
return redirect('shop/thankyou')
return self.get(**kwargs)
示例2: add_order
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import key [as 别名]
def add_order():
form = NewOrderForm()
if form.title.data != "":
drug_title = form.title.data
else: return json_response({'error': 'Drug title is empty'})
if form.weight.data != "":
drug_weight = form.weight.data
else: return json_response({'error': 'Drug weight is empty'})
token = str(uuid.uuid4())
order = Order(title = drug_title, weight = float(drug_weight), token = token)
order.put()
return json_response({
'id': int(order.key().id()),
'token': token,
'success': True
})