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


Python User.getDetail方法代码示例

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


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

示例1: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [as 别名]
 def post(self):    
     email     = self.get_argument("email",None)
     password  = self.get_argument("password",None)        
     import hashlib
     errMsg = None
     if email is None:
         errMsg = "Email不能为空"
         return self.render('login.html',user=self.currentUserInfo(),errMsg=errMsg)
     if password is None:
         errMsg = "Email不能为空"
         return self.render('login.html',user=self.currentUserInfo(),errMsg=errMsg)
     
     user_key = hashlib.md5(email).hexdigest()
     user = User()
     user_data = user.getDetail(user_key)
     
     if user_data is None:            
         errMsg = "用户不存在"
     else:
         if hashlib.md5(password).hexdigest() != user_data['password']:
             errMsg = "用户名或密码不正确"      
         else:
             urlname = user_data['nickname']                
             self.set_secure_cookie('user_email',user_data['email'])
             self.set_secure_cookie('user_nickname',urlname)
             self.set_secure_cookie('user_urlname',urlname)
             self.set_secure_cookie('user_key',user_key)
             self.set_secure_cookie('user_avatar',user_data['avatar'])
             #print "login succ!"
             return self.redirect('/')
             
     self.render('login.html',user=self.currentUserInfo(),errMsg=errMsg)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:34,代码来源:user.py

示例2: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [as 别名]
 def get(self,key):
     uri = self.request.uri
     request = {}
     pin = Pin()
     
     pin_keys = pin.getByKeyValues("board",key)
     pin_count = len(pin_keys)
     
     query = {}
     query['q']         = "board:%s" % key    
             
     query['start']  = "0"
     query['rows']   = globalSetting['max_index_pin_rows']
     query['sort']   = "createTime"
     
     if "page" in uri:
         request = urldecode(uri)
         page = int(request['page'])
         query['start']  = query['rows']*page
         if pin_count < query['rows']*page:
             return ''
     
     pin_data = pin.solr(query)
     print len(pin_data)
     
     marks_dict = pin.formatPins(pin_data)        
     
     if request:
         #print request['callback']
         #print request['page']            
         callback_result = {
                         'filter':'pin:index',
                         'pins':marks_dict
                         }
         
         callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
         self.set_header("Content-Type", "text/html; charset=utf-8")            
         return self.write(callback_response)
     else:
         marks = ''            
         for _mark_t in marks_dict:                
             marks = self.render_string('mark.html',mark=_mark_t)+marks
         board = Board()
         user = User()
         category = Category() 
  
         board_data = board.get(key)
         
         b_user = user.getDetail(board_data['user'])
         b_category = category.get(board_data['category'])
         b_keys = board.getByKeyValues("user", board_data['user'])
         
         if key in b_keys:
             b_keys.remove(key)
             
         b_boards = board.all(b_keys)
     
         self.render('board_pins_list.html',f_board = self.formatFollowBoardData(key), b_boards= b_boards,b_category = b_category,b_user=b_user,user=self.currentUserInfo(),board = board.get(key),marks=marks)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:60,代码来源:board.py

示例3: getByPin

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [as 别名]
    def getByPin(self, key):
        query = {}
        query["q"] = "pin:%s" % key
        query["sort"] = "createTime"
        comment_data = self.solr(query)

        # comment_keys = self.getByKeyValues('pin', key)
        # comment_data = self.all(comment_keys)
        user = User()
        res = []
        for row in comment_data:
            row["userInfo"] = user.getDetail(row["user"])
            res.append(row)
        return res
开发者ID:sousajmr,项目名称:ptpy,代码行数:16,代码来源:comment.py

示例4: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [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

示例5: getPinDetail

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [as 别名]
 def getPinDetail(self,key):        
     board = Board()
     user = User()
     thumb = Thumb()        
     pic = Pic()        
     comment = Comment()    
     
     marks_dict = []
     pin = self.get(key)
     _pin = {}
     _pin['pin']               = self.get(key)
     _pin['user']              = user.getDetail(pin['user'])
     _pin['pin']['pic']        = pic.get(pin['key'])['url']
     
     
     _pin['board']             = board.getDetailWithPinThumb(pin['board']) 
     
     _pin['comments']         = comment.getByPin( pin['key'])           
         
     return _pin
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:22,代码来源:pin.py

示例6: formatPins

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import getDetail [as 别名]
 def formatPins(self,data):        
     board = Board()
     user = User()
     thumb = Thumb()
     comment = Comment()    
     
     marks_dict = []
     
     for pin in data:
         _pin = {}
         _pin['pin']               = pin
         _pin['user']              = user.getDetail(pin['user'])
         _pin['thumb']             = thumb.get(pin['key'])
         
         _pin['board']             = board.getDetail(pin['board']) 
         #print _pin['board']
         _pin['comments']         = comment.getByPin( pin['key'])
         
         marks_dict.append(_pin)
         
     return marks_dict
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:23,代码来源:pin.py


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