本文整理汇总了Python中model.Shop.prompt方法的典型用法代码示例。如果您正苦于以下问题:Python Shop.prompt方法的具体用法?Python Shop.prompt怎么用?Python Shop.prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Shop
的用法示例。
在下文中一共展示了Shop.prompt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import prompt [as 别名]
def post(self, cid):
try:
category = Category.get(id = cid)
except:
self.flash("此分类不存在")
self.redirect("/admin/addshop")
return
categoryattrs = CategoryAttr.select().where(CategoryAttr.cid == cid)
cover = self.get_argument("cover", None)
pics = self.get_argument("pics", None)
name = self.get_argument("name", None)
ename = self.get_argument("ename", None)
price = str(float(str(self.get_argument("price", 0.0))))
level = int(self.get_argument("level", 3))
resume = self.get_argument("resume", "")
intro = self.get_argument("intro", "")
prompt = self.get_argument("prompt", "")
views = int(self.get_argument("views", 0))
try:
shop = Shop()
shop.name = name
shop.ename = ename
shop.cid = cid
shop.level = level
shop.resume = resume
shop.intro = intro
shop.prompt = prompt
shop.price = price
shop.views = views
args = {}
for categoryattr in categoryattrs:
caid = str(categoryattr.id)
args['attr_' + caid] = self.get_argument('attr_' + caid, '')
shop.args = simplejson.dumps(args)
if pics:
pics = pics.split(',')
pics = [pic.replace('/upload/', '') for pic in pics]
if not cover:
cover = pics[0]
if not cover:
cover = ''
shop.cover = cover.replace('/upload/', '')
shop.validate()
shop.save()
if isinstance(pics, list):
for pic in pics:
shoppic = ShopPic()
shoppic.sid = shop.id
shoppic.path = pic
shoppic.save()
self.flash(u"添加商品%s成功" % name, 'ok')
if category.id == 2:
self.redirect("/admin/shops")
else:
self.redirect("/admin/addshopattr/" + str(shop.id))
return
except Exception, ex:
self.flash(str(ex))