當前位置: 首頁>>代碼示例>>Python>>正文


Python Shop.price方法代碼示例

本文整理匯總了Python中model.Shop.price方法的典型用法代碼示例。如果您正苦於以下問題:Python Shop.price方法的具體用法?Python Shop.price怎麽用?Python Shop.price使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在model.Shop的用法示例。


在下文中一共展示了Shop.price方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from model import Shop [as 別名]
# 或者: from model.Shop import price [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))
開發者ID:FashtimeDotCom,項目名稱:cakeshop,代碼行數:71,代碼來源:admin.py


注:本文中的model.Shop.price方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。