当前位置: 首页>>代码示例>>Python>>正文


Python Shop.args方法代码示例

本文整理汇总了Python中model.Shop.args方法的典型用法代码示例。如果您正苦于以下问题:Python Shop.args方法的具体用法?Python Shop.args怎么用?Python Shop.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Shop的用法示例。


在下文中一共展示了Shop.args方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from model import Shop [as 别名]
# 或者: from model.Shop import args [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.args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。