本文整理汇总了Python中model.Comment.get方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get方法的具体用法?Python Comment.get怎么用?Python Comment.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get [as 别名]
def get(self,page):
code=OptionSet.getValue("Akismet_code",default="")
up=OptionSet.getValue("Akismet_Comments_v0.3",default=[])
if type(up)!=type([]):
up=[]
delkey = page.param('delkey')
rekey = page.param('rekey')
if rekey or delkey:
newup = []
for i in up:
cmtkey = i['key'][0];
enykey = i['key'][1];
if delkey and cmtkey==delkey:
cm = Comment.get(cmtkey)
db.Model.delete(cm)
elif rekey and cmtkey==rekey:
cm = Comment.get(cmtkey)
eny = Entry.get(enykey)
eny.commentcount+=1
eny.put()
cm.entry = eny
db.Model.put(cm)
self.SubmitAkismet({
'user_agent':i['other']['user_agent'],
'referrer':i['other']['referrer'],
'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')
},i['other'].get('url',''),"Ham")
else:
newup.append(i)
if not len(up)==len(newup):
OptionSet.setValue("Akismet_Comments_v0.3",newup)
up = newup
cmts = [(Comment.get(i['key'][0]),Entry.get(i['key'][1])) for i in up]
comments = [u'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a target="_blank" href="/%s">%s</a></td><td><a href="?delkey=%s" title="删除">删除</a> <a href="?rekey=%s" title="这不是一个垃圾评论">还原</a></td></tr>'%(i[0].date,
i[0].author,i[0].content,i[0].email,i[0].ip,i[1].link,i[1].title,str(i[0].key()),str(i[0].key())) for i in cmts]
comments = ''.join(comments)
apikey = OptionSet.getValue("Akismet_code",default=self.AKISMET_default_Key)
if len(apikey)<5:
apikey = self.AKISMET_default_Key
api = AkismetManager(apikey,Blog.all()[0].baseurl)
if not code:
status = ''
elif api.IsValidKey():
status = 'True'
else:
status = 'False'
return u'''<h3>Akismet</h3>
<form action="" method="post">
<p>Akismet Api Key:</p>
<input name="code" style="width:400px;" value="%s"> %s
<br />
<p>删除一条评论并提交Spam(输入评论的ID):</p>
<input name="spam" style="width:400px;" value="">
<br />
<input type="submit" value="submit">
</form>
<div>
<br />
<h3>被过滤的评论</h3> <table class="widefat"><thead><tr><th>日期</th><th>作者</th><th>内容</th><th>电子邮件</th><th>IP地址</th><th>文章/页面</th><th style="width:15%%;">选择操作</th></tr></thead><tbody>%s </tbody></table>
</div>'''%(code,status,comments)
示例2: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get [as 别名]
def get(self, page):
code = OptionSet.getValue("Akismet_code", default="")
up = OptionSet.getValue("Akismet_Comments_v0.3", default=[])
rm = OptionSet.getValue("Akismet_AutoRemove", False)
if type(up) != type([]):
up = []
delkey = page.param("delkey")
rekey = page.param("rekey")
if rekey or delkey:
newup = []
for i in up:
cmtkey = i["key"][0]
enykey = i["key"][1]
if delkey and cmtkey == delkey:
cm = Comment.get(cmtkey)
db.Model.delete(cm)
elif rekey and cmtkey == rekey:
cm = Comment.get(cmtkey)
eny = Entry.get(enykey)
eny.commentcount += 1
eny.put()
cm.entry = eny
db.Model.put(cm)
self.SubmitAkismet(
{
"user_agent": i["other"]["user_agent"],
"referrer": i["other"]["referrer"],
"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"),
},
i["other"].get("url", ""),
"Ham",
)
else:
newup.append(i)
if not len(up) == len(newup):
OptionSet.setValue("Akismet_Comments_v0.3", newup)
up = newup
cmts = [(Comment.get(i["key"][0]), Entry.get(i["key"][1])) for i in up]
comments = [
u'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a target="_blank" href="/%s">%s</a></td><td><a href="?delkey=%s" title="删除">删除</a> <a href="?rekey=%s" title="这不是一个垃圾评论">还原</a></td></tr>'
% (
i[0].date,
i[0].author,
i[0].content,
i[0].email,
i[0].ip,
i[1].link,
i[1].title,
str(i[0].key()),
str(i[0].key()),
)
for i in cmts
if i is not None and i[0] is not None
]
comments = "".join(comments)
apikey = OptionSet.getValue("Akismet_code", default=self.AKISMET_default_Key)
if len(apikey) < 5:
apikey = self.AKISMET_default_Key
api = AkismetManager(apikey, Blog.all()[0].baseurl)
if not code:
status = ""
elif api.IsValidKey():
status = "True"
else:
status = "False"
if rm == True:
rmchecked = 'checked="checked"'
else:
rmchecked = ""
return u"""<h3>Akismet</h3>
<form action="" method="post">
<p>Akismet Api Key:</p>
<input name="code" style="width:400px;" value="%s"> %s
<br />
<p>自动删除检测到的垃圾评论:
<input type="checkbox" name="autorm" value="1" %s></p>
<p>删除一条正常的评论并提交Spam(输入评论的ID):</p>
<input name="spam" style="width:400px;" value="">
<br />
<input type="submit" value="submit">
</form>
<div>
<br />
<h3>被过滤的评论</h3> <table class="widefat"><thead><tr><th>日期</th><th>作者</th><th>内容</th><th>电子邮件</th><th>IP地址</th><th>文章/页面</th><th style="width:15%%;">选择操作</th></tr></thead><tbody>%s </tbody></table>
</div>""" % (
code,
status,
rmchecked,
comments,
)