本文整理汇总了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
}
)
示例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)
示例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."'))
示例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)
})
示例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')))
示例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")
示例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