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


Python Article.get_article_by_id_simple方法代码示例

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


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

示例1: get

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_simple [as 别名]
 def get(self, id = ''):
     obj = Article.get_article_by_id_simple(id)
     if obj:
         self.redirect('%s/topic/%d/%s'% (BASE_URL, obj.id, obj.title), 301)
         return
     else:
         self.redirect(BASE_URL)
开发者ID:bibodeng,项目名称:pyWeiXin_SAElog,代码行数:9,代码来源:blog.py

示例2: get

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_simple [as 别名]
 def get(self, id = ''):
     obj = Article.get_article_by_id_simple(id)
     if obj:
         if MYSQL_TO_KVDB_SUPPORT:
             self.redirect('%s/topic/%s/%s'% (BASE_URL, obj['id'], obj['title']), 301)
         else:
             self.redirect('%s/topic/%d/%s'% (BASE_URL, obj.id, obj.title), 301)
         return
     else:
         self.redirect(BASE_URL)
开发者ID:yobin,项目名称:saepy-log,代码行数:12,代码来源:blog.py

示例3: post

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_simple [as 别名]
    def post(self, id = '', title = ''):
        action = self.get_argument("act")

        if action == 'inputpw':
            wrn = self.get_cookie("wrpw", '0')
            if int(wrn)>=10:
                self.write('403')
                return

            pw = self.get_argument("pw",'')
            pobj = Article.get_article_by_id_simple(id)
            if MYSQL_TO_KVDB_SUPPORT:
                psw = pobj['password']
                pobjid = pobj['id']
                pobjtitle = pobj['title']
            else:
                psw = pobj.password
                pobjid = pobj.id
                pobjtitle = pobj.title
            wr = False
            if pw:
                if psw == pw:
                    clear_cache_by_pathlist(['post:%s'%id])#yobin 20120630
                    self.set_cookie("rp%s" % id, psw, path = "/", expires_days =1)
                else:
                    wr = True
            else:
                wr = True
            if wr:
                wrn = self.get_cookie("wrpw", '0')
                self.set_cookie("wrpw", str(int(wrn)+1), path = "/", expires_days = 1 )
            self.redirect('%s/topic/%d/%s'% (BASE_URL, pobjid, pobjtitle))
            return

        self.set_header('Content-Type','application/json')
        rspd = {'status': 201, 'msg':'ok'}

        if action == 'readmorecomment':
            fromid = self.get_argument("fromid",'')
            allnum = int(self.get_argument("allnum",0))
            showednum = int(self.get_argument("showednum", EACH_PAGE_COMMENT_NUM))
            if fromid:
                rspd['status'] = 200
                if (allnum - showednum) >= EACH_PAGE_COMMENT_NUM:
                    limit = EACH_PAGE_COMMENT_NUM
                else:
                    limit = allnum - showednum
                cobjs = Comment.get_post_page_comments_by_id( id, int(fromid), limit )
                rspd['commentstr'] = self.render('comments.html', {'cobjs': cobjs})
                rspd['lavenum'] = allnum - showednum - limit
                self.write(json.dumps(rspd))
            return

        #
        usercomnum = self.get_cookie('usercomnum','0')
        if int(usercomnum) > MAX_COMMENT_NUM_A_DAY:
            rspd = {'status': 403, 'msg':'403: Forbidden'}
            self.write(json.dumps(rspd))
            return

        try:
            timestamp = int(time())
            post_dic = {
                'author': self.get_argument("author"),
                'email': self.get_argument("email",''),
                'content': safe_encode(self.get_argument("con").replace('\r','\n')),
                'url': self.get_argument("url",''),
                'postid': self.get_argument("postid"),
                'add_time': timestamp,
                'toid': self.get_argument("toid",''),
                'visible': COMMENT_DEFAULT_VISIBLE
            }
        except:
            rspd['status'] = 500
            rspd['msg'] = '错误: 注意必填的三项'
            self.write(json.dumps(rspd))
            return

        pobj = Article.get_article_by_id_simple(id)
        if MYSQL_TO_KVDB_SUPPORT:
            pclosecomment = pobj['closecomment']
            pcomment_num  = int(pobj['comment_num'])
            pobjid        = pobj['id']
            pobjtitle     = pobj['title']
        else:
            pclosecomment = pobj.closecomment
            pcomment_num  = pobj.comment_num
            pobjid        = pobj.id
            pobjtitle     = pobj.title

        try:
            pclosecomment = int(pclosecomment)
        except Exception , e:
            print 'PostDetail, pclosecomment=',pclosecomment,e
开发者ID:yobin,项目名称:saepy-log,代码行数:96,代码来源:blog.py

示例4: post

# 需要导入模块: from model import Article [as 别名]
# 或者: from model.Article import get_article_by_id_simple [as 别名]
 def post(self, id = '', title = ''):
     action = self.get_argument("act")
     
     if action == 'inputpw':
         wrn = self.get_cookie("wrpw", '0')
         if int(wrn)>=10:
             self.write('403')
             return
         
         pw = self.get_argument("pw",'')
         pobj = Article.get_article_by_id_simple(id)
         wr = False
         if pw:             
             if pobj.password == pw:
                 self.set_cookie("rp%s" % id, pobj.password, path = "/", expires_days =1)
             else:
                 wr = True
         else:
             wr = True
         if wr:
             wrn = self.get_cookie("wrpw", '0')
             self.set_cookie("wrpw", str(int(wrn)+1), path = "/", expires_days = 1 )
         
         self.redirect('%s/topic/%d/%s'% (BASE_URL, pobj.id, pobj.title))
         return
     
     self.set_header('Content-Type','application/json')
     rspd = {'status': 201, 'msg':'ok'}
     
     if action == 'readmorecomment':
         fromid = self.get_argument("fromid",'')
         allnum = int(self.get_argument("allnum",0))
         showednum = int(self.get_argument("showednum", EACH_PAGE_COMMENT_NUM))
         if fromid:
             rspd['status'] = 200
             if (allnum - showednum) >= EACH_PAGE_COMMENT_NUM:
                 limit = EACH_PAGE_COMMENT_NUM
             else:
                 limit = allnum - showednum
             cobjs = Comment.get_post_page_comments_by_id( id, fromid, limit )
             rspd['commentstr'] = self.render('comments.html', {'cobjs': cobjs})
             rspd['lavenum'] = allnum - showednum - limit
             self.write(json.dumps(rspd))
         return
     
     #
     usercomnum = self.get_cookie('usercomnum','0')
     if int(usercomnum) > MAX_COMMENT_NUM_A_DAY:
         rspd = {'status': 403, 'msg':'403: Forbidden'}
         self.write(json.dumps(rspd))
         return
     
     try:
         timestamp = int(time())
         post_dic = {
             'author': self.get_argument("author"),
             'email': self.get_argument("email"),
             'content': safe_encode(self.get_argument("con").replace('\r','\n')),
             'url': self.get_argument("url",''),
             'postid': self.get_argument("postid"),
             'add_time': timestamp,
             'toid': self.get_argument("toid",''),
             'visible': COMMENT_DEFAULT_VISIBLE
         }
     except:
         rspd['status'] = 500
         rspd['msg'] = '错误: 注意必填的三项'
         self.write(json.dumps(rspd))
         return
     
     pobj = Article.get_article_by_id_simple(id)
     if pobj and not pobj.closecomment:
         cobjid = Comment.add_new_comment(post_dic)
         if cobjid:
             Article.update_post_comment( pobj.comment_num+1, id)
             rspd['status'] = 200
             #rspd['msg'] = '恭喜: 已成功提交评论'
             
             rspd['msg'] = self.render('comment.html', {
                     'cobjid': cobjid,
                     'gravatar': 'http://www.gravatar.com/avatar/%s'%md5(post_dic['email']).hexdigest(),
                     'url': post_dic['url'],
                     'author': post_dic['author'],
                     'visible': post_dic['visible'],
                     'content': post_dic['content'],
                 })
             
             clear_cache_by_pathlist(['/','post:%s'%id])
             #send mail
             if not debug:
                 try:
                     if NOTICE_MAIL:
                         tolist = [NOTICE_MAIL]
                     else:
                         tolist = []
                     if post_dic['toid']:
                         tcomment = Comment.get_comment_by_id(toid)
                         if tcomment and tcomment.email:
                             tolist.append(tcomment.email)
                     commenturl = "%s/t/%s#r%s" % (BASE_URL, str(pobj.id), str(cobjid))
#.........这里部分代码省略.........
开发者ID:bibodeng,项目名称:pyWeiXin_SAElog,代码行数:103,代码来源:blog.py


注:本文中的model.Article.get_article_by_id_simple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。