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


Python Comment.data['user']方法代码示例

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


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

示例1: post

# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import data['user'] [as 别名]
 def post(self):
     import hashlib,time
     user_key      = self.get_secure_cookie('user_key')        
     pin_key       = self.get_argument("pinid",None)
     nickname      = self.get_secure_cookie('user_nickname')
     rawtext       = self.get_argument("text",None)
     res = {}
     if rawtext is None:
         res['code'] = 1
         res['data'] = "请输入评论"
         body = json.dumps(res)
         self.set_header("Content-Type", "text/json; charset=UTF-8")
         self.write(body)
     
     comment = Comment()
     _tmp = "%s%s" % (user_key,rawtext)
     key = comment.genKey(_tmp)
     
     comment.key = key
     comment.data['rawtext'] = rawtext
     comment.data['user']    = user_key
     comment.data['pin']     = pin_key
     comment.data['createTime']     = int(time.time())
     
     try: 
         comment.post()
     except Exception as what:
         print what
         res['code'] = 1
         res['data'] = what
     else:            
         res['code'] = 0
         res['data'] = "sucess"
         obj  = {}
         user = User()
         obj['key']        = comment.key
         obj['userInfo']   = user.getDetail(user_key)
         obj['rawtext']    = comment.data['rawtext']
         obj['createTime'] = comment.data['createTime']
         print obj['userInfo']
         res['obj'] = obj
       
     body = json.dumps(res)
     print body
     self.set_header("Content-Type", "text/json; charset=UTF-8")
     self.write(body)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:48,代码来源:comments.py


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