本文整理汇总了Python中models.Item.allocate_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Item.allocate_ids方法的具体用法?Python Item.allocate_ids怎么用?Python Item.allocate_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Item
的用法示例。
在下文中一共展示了Item.allocate_ids方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createItem
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import allocate_ids [as 别名]
def createItem(self,request):
i_id = Item.allocate_ids(size=1)[0]
i_key = ndb.Key(Item, i_id)
data = {field.name: getattr(request, field.name) for field in request.all_fields()}
data['key'] = i_key
Item(**data).put()
return self._copyItemToForm(i_key.get())
示例2: placeOrder
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import allocate_ids [as 别名]
def placeOrder(self,request):
print "creating Customer"
o_id = Item.allocate_ids(size=1)[0]
data = {}
for field in request.all_fields():
if field.name == 'custId':
data[field.name] = ndb.Key(Customer,getattr(request,field.name))
c_key = ndb.Key(Customer,getattr(request,field.name))
o_key = ndb.Key(Order, o_id,parent=data[field.name])
else:
if field.name == 'itemId':
data[field.name] = ndb.Key(Item,getattr(request,field.name))
obj = (ndb.Key(Item,getattr(request,field.name))).get()
price = obj.itemPrice
else:
if field.name == 'credit':
credit = getattr(request,field.name)
else:
if field.name == 'orderDate':
if getattr(request,field.name) == None:
data[field.name] = datetime.datetime.now()
else:
data[field.name] = datetime.datetime.strptime(getattr(request,field.name), '%m/%d/%y:%H:%M:%S')
else:
data[field.name] = getattr(request,field.name)
data['key'] = o_key
data['orderPrice'] = price * data['itemQuantity']
if(data['itemQuantity']>=0):
Order(**data).put()
self.update_customer_credit_debit_total(data,c_key,credit)
self.update_dailyorder(data)
return self._copyOrderToForm(o_key.get())
示例3: update_dailyorder
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import allocate_ids [as 别名]
def update_dailyorder(self,data):
query = DailyOrder.query(ndb.AND(DailyOrder.custId == data['custId'] , DailyOrder.itemId == data['itemId'], DailyOrder.orderDate == data['orderDate']))
logging.debug(data['orderDate'])
logging.debug(query)
x=0
for q in query:
data['key'] = q.key
data['itemQuantity'] = q.itemQuantity + data['itemQuantity']
data['orderPrice'] = q.orderPrice + data['orderPrice']
data['orderDate'] = q.orderDate
x=1
if x:
print "i"
else:
print "else mai hun"
do_id = Item.allocate_ids(size=1)[0]
do_key = ndb.Key(DailyOrder, do_id)
data['key'] = do_key
DailyOrder(**data).put()