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


Python Card.get_by_cid方法代碼示例

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


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

示例1: post

# 需要導入模塊: from models.card import Card [as 別名]
# 或者: from models.card.Card import get_by_cid [as 別名]
 def post(self):
     cid = self.get_argument('cid')
     root = self.get_secure_cookie('root')
     if root != 'suiyue':
         return self.redirect('/rootlogin')
     cards = Card.get_by_cid(cid)
     ext_allowed = ['gif', 'jpg', 'jpeg', 'png']
     cpic = cards[0].pic
     max_size = 2621440
     save_dir = os.path.join(os.path.dirname(__file__), "../public/pic/card/")
     if len(cards)>0:
         file_name = str(cards[0].cid)
         error = ""
         if 'image' in self.request.files:
             pic = self.request.files['image'][0]
             ext = pic['filename'].split('.').pop()
             if ext not in ext_allowed:
                 error="圖片格式不支持"
                 self.redirect('/control')
             if len(pic['body'])>max_size:
                 error="圖片太大"
                 self.redirect('/control')
             cpic = file_name+"."+ext
             with open(save_dir+cpic,'wb') as up:
                 up.write(pic['body'])
         Card.change_pic(cid, cpic)
         self.redirect("/control")
     else:
         self.redirect('/control')
開發者ID:oujiaqi,項目名稱:suiyue,代碼行數:31,代碼來源:control.py

示例2: get

# 需要導入模塊: from models.card import Card [as 別名]
# 或者: from models.card.Card import get_by_cid [as 別名]
 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     order = get_order()
     card = Card.get_by_porder(order)
     cid = self.get_argument("cid",None)
     if cid is not None:
         card=Card.get_by_cid(cid)
     article = Article.get_all_Acard(200)
     usedCard = Card.get_all_card()
     temp = []
     for one in usedCard:
         if 0 < one.porder and one.porder <= order:
             temp.append(one)
     usedCard = temp
     reArticles = Article.get_all(200)
     Rarticle = sorted(reArticles,BaseHandler.rank)
     if len(Rarticle) > 6:
         Rarticle = Rarticle[:6]
     Ruser = User.get_all_user(100)
     if len(Ruser)>9:
         Ruser = Ruser[:9]
     if len(usedCard)>3:
         usedCard = usedCard[:3]
     self.render("card.html",user=user,Rarticle=Rarticle,Article=article,usedCard=usedCard,Ruser=Ruser,card=card)
開發者ID:oujiaqi,項目名稱:suiyue,代碼行數:27,代碼來源:card.py

示例3: get

# 需要導入模塊: from models.card import Card [as 別名]
# 或者: from models.card.Card import get_by_cid [as 別名]
 def get(self):
     uname=self.get_current_user()
     user=User.get_user_by_name(uname)
     if len(user) > 0:
         cid = self.get_argument("cid", None)
         sid = self.get_argument("sid", None)
         Class = "free"
         if cid is not None:
             Class="card"
         elif sid is not None:
             Class="story"
         card=Card.get_by_cid(cid)
         story=Story.get_by_sid(sid)
         self.render("write.html",user=user,card=card,story=story,Class=Class)
     else:
         self.redirect("/login")
開發者ID:oujiaqi,項目名稱:suiyue,代碼行數:18,代碼來源:write.py


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