本文整理汇总了Python中model.Comment.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get_by_id方法的具体用法?Python Comment.get_by_id怎么用?Python Comment.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.get_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def post(self):
# this method is reserved for AJAX call to this object
# json response
result = {'message': ""}
comment_id = self.request.POST.get("comment_id", "")
operation = self.request.POST.get("operation", "")
logging.info("CommentManager, post data: comment_id = %s, operation = %s" % (comment_id, operation))
if comment_id:
comment = Comment.get_by_id(long(comment_id))
if comment:
if operation == "delete":
# update entry.commentcount
comment.entry.commentcount -= 1
comment.entry.put()
# delete this comment
comment.delete()
result['message'] = "comment '%s' has been deleted" % (comment_id)
else:
result['message'] = "unknown operation %s" % (operation)
else:
result['message'] = "unknown comment id %s" % (comment_id)
else:
result['message'] = "empty comment id"
json_response = json.encode(result)
logging.info("json response: %s" % (json_response))
self.response.content_type = "application/json"
return self.response.out.write(json_response)
示例2: post
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def post(self,page):
code=page.param("code")
OptionSet.setValue("Akismet_code",code)
rm=page.param('autorm')
if rm and int(rm)==1:
rm=True
else:
rm=False
oldrm = OptionSet.getValue("Akismet_AutoRemove",False)
if oldrm!=rm:
OptionSet.setValue("Akismet_AutoRemove",rm)
spam=page.param("spam")
spam = len(spam)>0 and int(spam) or 0
sOther = ""
if spam>0:
cm = Comment.get_by_id(spam)
try:
url = Blog.all().fetch(1)[0].baseurl
self.SubmitAkismet({
'user_ip' : cm.ip,
'comment_type' : 'comment',
'comment_author' : cm.author.encode('utf-8'),
'comment_author_email' : cm.email,
'comment_author_url' : cm.weburl,
'comment_content' : cm.content.encode('utf-8')
},url,"Spam")
sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>评论已删除</div>"
cm.delit()
except:
sOther = u"<div style='padding:8px;margin:8px;border:1px solid #aaa;color:red;'>无法找到对应的评论项</div>"
return sOther + self.get(page)
示例3: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def get(self,commID):
comm = Comment.get_by_id(int(commID))
if comm is None:
return self.redirect('/')
post = comm.post
post.commentcount -= 1
link = comm.post.full_permalink()
comm.delete()
util.flushRecentComment()
return self.redirect(link)
示例4: post
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def post(self):
try:
checkList = self.request.get_all('checks')
for key in checkList:
keyID = int(key)
comment=Comment.get_by_id(keyID)
comment.delete()
finally:
self.redirect('/admin/comments')
return
示例5: post
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def post(self, comment_id=0):
'''Updating the comment and redirecting back to the photo page.'''
user_id, user = self.get_user()
if not user:
self.redirect('/')
return
comment_id = int(comment_id)
comment = Comment.get_by_id(comment_id)
error, data = self._check(user, comment)
if error:
self.render('error.html', **data)
comment_text = self.request.get('comment-text')
photo_id = int(self.request.get('photo_id'))
logging.info(comment_text)
logging.info(photo_id)
comment.text = comment_text
comment.put()
self.redirect('/photo/{}'.format(photo_id))
示例6: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_by_id [as 别名]
def get(self, comment_id=0):
'''Edit a comment'''
user_id, user = self.get_user()
if not user:
self.redirect('/')
return
comment_id = int(comment_id)
comment = Comment.get_by_id(comment_id)
error, data = self._check(user, comment)
if error:
self.render('error.html', **data)
return
data = {
'page_title': 'Edit Comment',
'user': user,
'userid': user_id,
'comment': comment,
'photo_id': comment.photo.id(),
}
self.render('comment-edit.html', **data)