本文整理汇总了Python中models.Order.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Order.to_dict方法的具体用法?Python Order.to_dict怎么用?Python Order.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.to_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_g_to_o
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import to_dict [as 别名]
def add_g_to_o(params):
print "adding"
g_path = STORAGE_ROOT+'/good-'+params['name']+'_'+params['country']+'_'+params['g_id']+'.json'
t_good = json.load(open(g_path, 'r'))
t_good = dict_to_good(t_good)
print t_good
o_path = STORAGE_ROOT+'/order-'+params['to']+'_'+params['ord_c']+'_'+params['o_id']+'.json'
t_order = json.load(open(o_path, 'r'))
#print t_good, t_order
new_order = Order(t_order['name'], t_order['country'], datetime.strptime(t_order['delivery_time'], '%d.%m.%Y').strftime('%d.%m.%Y'))
new_order.goods = dict_to_goods(t_order['goods'])
new_order.price_of_order = int(t_order['price']) + int(t_good.good_price)
new_order.goods.append(t_good)
obj = new_order.to_dict()
full_path = "%s\%s-%s_%s_%s.json" % (STORAGE_ROOT, 'order', new_order.order_name, new_order.delivery_country,
params['o_id'])
wfile = open(full_path, 'w')
json.dump(obj, wfile)
wfile.close()