本文整理汇总了Python中model.Comment.all方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.all方法的具体用法?Python Comment.all怎么用?Python Comment.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_basic_info
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def update_basic_info(
update_categories=False,
update_tags=False,
update_links=False,
update_comments=False,
update_archives=False,
update_pages=False):
from model import Entry,Archive,Comment,Category,Tag,Link
basic_info = ObjCache.get(is_basicinfo=True)
if basic_info is not None:
info = ObjCache.get_cache_value(basic_info.cache_key)
if update_pages:
info['menu_pages'] = Entry.all().filter('entrytype =','page')\
.filter('published =',True)\
.filter('entry_parent =',0)\
.order('menu_order').fetch(limit=1000)
if update_archives:
info['archives'] = Archive.all().order('-year').order('-month').fetch(12)
if update_comments:
info['recent_comments'] = Comment.all().order('-date').fetch(5)
if update_links:
info['blogroll'] = Link.all().filter('linktype =','blogroll').fetch(limit=1000)
if update_tags:
info['alltags'] = Tag.all().order('-tagcount').fetch(limit=100)
if update_categories:
info['categories'] = Category.all().fetch(limit=1000)
logging.debug('basic_info updated')
basic_info.update(info)
示例2: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def get(self, page_slug=""):
if page_slug:
t_values = {}
posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
if posts.count() == 1:
logging.warning("find one page with slug=%s" % (page_slug))
posts = posts.fetch(limit=1)
post = posts[0]
t_values['post'] = post
# dump(post)
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
t_values['comments'] = comments
else:
logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("page.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
示例3: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def get(self, page_id="", operation=""):
# find all comments, and list all comments
t_values = {}
logging.info("CommentManager get")
# show all comments
comments = Comment.all().order("entry")
t_values['comments'] = comments
return self.response.out.write(render_template("comments.html", t_values, "", True))
示例4: getRecentComment
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def getRecentComment():
key_ = "recent_comments"
comms = memcache.get(key_)
if comms is not None:
return comms
else:
comms = Comment.all().order('-date').fetch(8)
for comm in comms:
comm.content = re.sub(u'<[^>]*?>','',comm.content)[:50]
if not memcache.add(key_, comms, 3600):
logging.error("Memcache set failed.")
return comms
示例5: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def get(self):
current_user = users.get_current_user()
votes = Votes.for_user(current_user)
team_comments = {}
user_comments = {}
if shouldShowComments():
comments = Comment.all()
for comment in comments:
team_key = str(comment.team.key())
comment.author_name = generateCommentAuthorName(comment)
if not team_key in team_comments:
team_comments[team_key] = []
if comment.user == current_user:
user_comments[team_key] = comment
team_comments[team_key].append(comment)
all_teams = filter_hidden(Team.all().fetch(1000))
for team in all_teams:
team.voted = (team.key() in votes.local_teams or team.key() in votes.teams)
team_key = str(team.key())
if shouldShowComments():
if team_key in team_comments:
team.comments = team_comments[team_key]
if team_key in user_comments:
team.user_comment = user_comments[team_key].text
logout_url = users.create_logout_url("/")
winning_teams = filter(lambda x: config['highlight_winners'] and x.annotation is not None and x.annotation != '', all_teams)
all_teams = filter(lambda x: x not in winning_teams, all_teams)
# Disable randomness for commenting always
if config["list_teams_randomly"] and not shouldEnableCommenting():
random.shuffle(all_teams)
random.shuffle(winning_teams)
self.render('list', { 'teams': all_teams,
'winning_teams': winning_teams,
'votes': votes,
'team_comments': team_comments,
'user_comments': user_comments,
'highlight_winners': config['highlight_winners'],
'enable_voting': config['enable_voting'],
'enable_commenting': shouldEnableCommenting(),
'show_winner_entry': config['show_winner_entry'],
'logout_url': logout_url })
示例6: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def get(self):
current_user = users.get_current_user()
votes = Votes.for_user(current_user)
team_comments = {}
user_comments = {}
if shouldShowComments():
comments = Comment.all()
for comment in comments:
team_key = str(comment.team.key())
comment.author_name = comment.user.nickname().split('@', 1)[0]
if not team_key in team_comments:
team_comments[team_key] = []
if comment.user == current_user:
user_comments[team_key] = comment
team_comments[team_key].append(comment)
all_teams = Team.all().fetch(1000)
for team in all_teams:
team.voted = (team.key() in votes.local_teams or team.key() in votes.teams)
team_key = str(team.key())
if shouldShowComments():
if team_key in team_comments:
team.comments = team_comments[team_key]
if team_key in user_comments:
team.user_comment = user_comments[team_key].text
logout_url = users.create_logout_url("/")
# Disable randomness for commenting always
if config["list_teams_randomly"] and not shouldEnableCommenting():
random.shuffle(all_teams)
self.render('list', { 'teams': all_teams,
'votes': votes,
'team_comments': team_comments,
'user_comments': user_comments,
'enable_voting': config['enable_voting'],
'enable_commenting': shouldEnableCommenting(),
'logout_url': logout_url })
示例7: post
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def post(self, post_slug=""):
if post_slug:
t_values = {}
post_id = self.request.POST['post_id']
post = Entry.get_by_id(long(post_id))
if post:
# ok, we find the post, try to add comment to this post
logging.warning("find one post with post_id %s" % (post_id))
t_values['post'] = post
# dump(post)
# check google recaptcha, these two fileds might not exist due to connection to reCAPTCHA
recaptcha_challenge_field = self.request.POST.get('recaptcha_challenge_field', "")
recaptcha_response_field = self.request.POST.get('recaptcha_response_field', "")
remote_ip = self.request.environ['REMOTE_ADDR']
private_key = "6LdwFdISAAAAAOYRK7ls3O-kXPTnYDEstrLM2MRo"
antispam_flag = False
try:
result = submit(recaptcha_challenge_field, recaptcha_response_field, private_key, remote_ip)
logging.info("google recaptcha %s, %s" % (result.is_valid, result.error_code))
if result.is_valid:
antispam_flag = True
except:
e = sys.exc_info()[0]
logging.info(e)
# create comment for this post
if antispam_flag:
logging.info("PostManager - add comment")
comm_author = self.request.POST['author']
comm_email = self.request.POST['email']
comm_weburl = self.request.POST['weburl']
comm_content = self.request.POST['comment']
comment_ip = self.request.environ['REMOTE_ADDR']
comm = Comment(entry=post, author=comm_author, email=comm_email, weburl=comm_weburl, content=comm_content, ip=comment_ip)
comm.put()
t_values['alert_message'] = "Thanks %s for your comment!" % (comm_author)
else:
logging.warning("comment ignored because antispam failed")
t_values['alert_message'] = "Sorry, your comment was ignored because of reCAPTCHA failure!"
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
logging.info("PostHandler, post, find %d comments" % (comments.count()))
if post_id:
# only update commentcount when new comment is added
post.commentcount = comments.count()
post.put()
t_values['comments'] = comments
else:
logging.warning("post_id %s does not exist" % (post_id))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("post.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
示例8: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import all [as 别名]
def get(self):
comments=Comment.all().order('-commentTime')
values = {'comments':comments}
self.generateBasePage('manage/comments.html', values)
return