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


Python Comment.post方法代码示例

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


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

示例1: post

# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import post [as 别名]
 def post(self):
   verify = self.request.get('sdamwegmw')
   if verify != "AfnGDASsdafSA" :
     return self.error(403)
   post_id_ = self.request.get('post_id')
   post = Post.get_by_id(int(post_id_))
   if post is None:
     return self.redirect('/')
   comment = Comment()
   comment.post = post
   comment.author = self.request.get('comm_name')
   if users.is_current_user_admin():
     comment.author_is_admin = True
   comment.authorEmail = self.request.get('comm_email')
   comment.authorWebsite = self.request.get('comm_url')
   comment.content = self.request.get('comment')
   comment.userIp = self.request.remote_addr
   user = users.get_current_user()
   if user is not None:
     comment.user = user
     comment.author = str(user.nickname())
     comment.authorEmail = str(user.email()) 
   cookies = Cookie.SimpleCookie()
   cookies['comm_name'] = urllib.quote(comment.author.encode('utf8')) 
   cookies['comm_name']['path'] = '/'
   cookies['comm_name']['max-age'] = 3600*24*365
   cookies['comm_email'] = comment.authorEmail  
   cookies['comm_email']['path'] = '/'
   cookies['comm_email']['max-age'] = 3600*24*365
   cookies['comm_url'] = comment.authorWebsite 
   cookies['comm_url']['path'] = '/'
   cookies['comm_url']['max-age'] = 3600*24*365
   output_headers = []
   output_headers.append('%s\r\n' % cookies)
   for header in output_headers:
     sys.stdout.write(header)         
   comment.save()
   util.flushRecentComment()
   return self.redirect(post.full_permalink())
开发者ID:BlowBlood,项目名称:blowblood,代码行数:41,代码来源:blog.py


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