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


Python Comment.all方法代码示例

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


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

示例1: GET

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
    def GET(self,slug=None):
        try:
            page_index=int(self.param('page'))
        except:
            page_index=1



        cq=self.param('cq')
        cv=self.param('cv')
        if cq and cv:
            query=Comment.all().filter(cq+' =',cv).order('-date')
        else:
            query=Comment.all().order('-date')
        comments,pager=Pager(query=query,items_per_page=15).fetch(page_index)

        self.render2('views/admin/comments.html',
         {
           'current':'comments',
           'comments':comments,
           'pager':pager,
           'cq':cq,
           'cv':cv
          }
        )
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:27,代码来源:views.py

示例2: home

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
def home( request ):
    # get ongoing sub events
    subs = Subevent.all().filter( 'is_done =',False ).filter( 'start_date <=',today() )
    se_list = []
    for se in subs:
        item = {'se':se,
                'days':( se.end_date - today() ).days}
        se_list.append( item )
        
    se_list = sorted(se_list,key=lambda x:x['days'])
    # get recent history operation
    hi_list = History.all().order('-publish_time').fetch(5)
    comments = Comment.all().order('-publish_time').fetch(5)
    # get recent messages
    mes_li = Mes.all().order('-publish_time').fetch(5)

    tip = Tip.all().order('-publish_time').get()
    if tip:
        tip_content = tip.content
    else:
        tip_content = None
    c = Context({
                  'logouturl':users.create_logout_url('/login'),
                  'loginurl':LOGIN,
                  'cur_user':CURUSER,
                  'is_admin':users.is_current_user_admin(),
                  'se_list':se_list,
                  'hi_list':hi_list,
                  'comments':comments,
                  'mes_li':mes_li,
                  'tip':tip_content,
                 })
    return render_to_response('home.htm',c)
开发者ID:beachboysqq,项目名称:gansha,代码行数:35,代码来源:views.py

示例3: action_init_blog

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
    def action_init_blog(self,slug=None):

        for com in Comment.all():
            com.delete()

        for entry in Entry.all():
            entry.delete()

        self.blog.entrycount=0
        self.blog.save()
        self.write(_('"Init has succeed."'))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:13,代码来源:views.py

示例4: initialize

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
 def initialize(self, request):
     m_pages=Entry.all().filter('entrytype =','page')\
         .filter('published =',True)\
         .filter('entry_parent =',0)\
         .order('menu_order')
     blogroll=Link.all().filter('linktype =','blogroll')
     archives=Archive.all().order('-year').order('-month').fetch(12)
     alltags=Tag.all()
     self.template_vals.update({
                     'menu_pages':m_pages,
                     'categories':Category.all(),
                     'blogroll':blogroll,
                     'archives':archives,
                     'alltags':alltags,
                     'recent_comments':Comment.all().order('-date').fetch(5)
     })
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:18,代码来源:views.py

示例5: action_getcomments

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
    def action_getcomments(self):
        key=self.param('key')
        entry=Entry.get(key)
        comments=Comment.all().filter(entry = key)

        commentuser=self.request.cookies.get('comment_user', '')
        if commentuser:
            commentuser=commentuser.split('#@#')
        else:
            commentuser=['','','']


        vals={
            'entry':entry,
            'comments':comments,
            'user_name':commentuser[0],
            'user_email':commentuser[1],
            'user_url':commentuser[2],
            'checknum1':random.randint(1,10),
            'checknum2':random.randint(1,10),
            }
        html=self.get_render('comments',vals)

        self.write(simplejson.dumps(html.decode('utf8')))
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:26,代码来源:views.py

示例6: POST

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
    def POST(self,slug=None,postid=None):
        '''handle trackback'''
        error = '''<?xml version="1.0" encoding="utf-8"?>
<response>
<error>1</error>
<message>%s</message>
</response>
'''
        success = '''<?xml version="1.0" encoding="utf-8"?>
<response>
<error>0</error>
</response>
'''

        if not self.blog.allow_trackback:
            self.response.out.write(error % "Trackback denied.")
            return
        self.response.headers['Content-Type'] = "text/xml"
        if postid:
            entries = Entry.all().filter(published = True).filter(post_id = postid)[0:1]#.fetch(1)
        else:
            slug=urldecode(slug)
            entries = Entry.all().filter(published = True).filter(link = slug)[0:1]#.fetch(1)

        if not entries or len(entries) == 0 :#or  (postid and not entries[0].link.endswith(self.blog.default_link_format%{'post_id':postid})):
            self.response.out.write(error % "empty slug/postid")
            return
        #check code ,rejest spam
        entry=entries[0]
        logging.info(self.request.remote_addr+self.request.path+" "+entry.trackbackurl)
        #key=self.param("code")
        #if (self.request.uri!=entry.trackbackurl) or entry.is_external_page or not entry.allow_trackback:
        #import cgi
        from urlparse import urlparse
        param=urlparse(self.request.uri)
        code=param[4]
        param=cgi.parse_qs(code)
        if param.has_key('code'):
            code=param['code'][0]

        if  (not str(entry.key())==code) or entry.is_external_page or not entry.allow_trackback:
            self.response.out.write(error % "Invalid trackback url.")
            return


        coming_url = self.param('url')
        blog_name = myfilter.do_filter(self.param('blog_name'))
        excerpt = myfilter.do_filter(self.param('excerpt'))
        title = myfilter.do_filter(self.param('title'))

        if not coming_url or not blog_name or not excerpt or not title:
            self.response.out.write(error % "not enough post info")
            return

        import time
        #wait for half second in case otherside hasn't been published
        time.sleep(0.5)

##        #also checking the coming url is valid and contains our link
##        #this is not standard trackback behavior
##        try:
##
##            result = urlfetch.fetch(coming_url)
##            if result.status_code != 200 :
##                #or ((self.blog.baseurl + '/' + slug) not in result.content.decode('ascii','ignore')):
##                self.response.out.write(error % "probably spam")
##                return
##        except Exception, e:
##            logging.info("urlfetch error")
##            self.response.out.write(error % "urlfetch error")
##            return

        comment = Comment.all().filter(entry = entry).filter(weburl = coming_url).get()
        if comment:
            self.response.out.write(error % "has pinged before")
            return

        comment=Comment(author=blog_name,
                content="...<strong>"+title[:250]+"</strong> " +
                        excerpt[:250] + '...',
                weburl=coming_url,
                entry=entry)

        comment.ip=self.request.remote_addr
        comment.ctype=COMMENT_TRACKBACK
        try:
            comment.save()

            memcache.delete("/"+entry.link)
            self.write(success)
            self.blog.tigger_action("pingback_post",comment)
        except:
            self.response.out.write(error % "unknow error")
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:95,代码来源:views.py

示例7: wwb_list_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import all [as 别名]
def wwb_list_comment():   
    html = ''
    for comment in Comment.all()[:10]:
        html += '<li><a href=\"%s">%s</a></li>'%(comment.post.get_absolute_url(), comment.content.encode('utf-8'))
    return html
开发者ID:kylewu,项目名称:wwb_wwblog,代码行数:7,代码来源:wwb_fun.py


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