예제 #1
0
파일: user.py 프로젝트: aviatorBeijing/ptpy
    def get(self,key):
        uri = self.request.uri
        request = {}
        board = Board()
        
        pin_keys = board.allKey()
        pin_count = len(pin_keys)
        
        query = {}
        query['q']         = "user:%s" % key
                
        query['start']  = "0"
        query['rows']   = globalSetting['max_index_board_rows']
        query['sort']   = "follow"
        
        if "page" in uri:
            request = urldecode(uri)
            page = int(request['page'])
            query['start']  = query['rows']*page
            #if pin_count < query['rows']*page:
            #    return ''
        
        board_data = board.solr(query)
        print len(board_data)
                
        boards_dict = board.formatBoards(board_data)

        if request:
            #print request['callback']
            #print request['page']            
            callback_result = {
                            'filter':'board:index',
                            'boards':boards_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:            
            user = User()
            boards = ''
            for _board_t in boards_dict:
                boards = self.render_string('board_unit.html',board=_board_t) + boards
                
            u_user = user.getInfo(key)
            
            userFollow = UserFollow()
            counts = {}
            counts['follow'] = len(userFollow.getByKeyValues("user", key))
            
            counts['fans'] = len(userFollow.getByKeyValues("follow", key)) 
 
            self.render('user_board.html',counts=counts,u_user=u_user,user=self.currentUserInfo(),boards=boards)    
예제 #2
0
    def get(self):
        uri = self.request.uri
        request = {}
        board = Board()
        
        pin_keys = board.allKey()
        
        query = {}
        query['q']         = "public:1"
                
        query['start']  = "0"
        query['rows']   = globalSetting['max_index_board_rows']
        query['sort']   = "follow"
        
        if "page" in uri:
            request = urldecode(uri)
            page = int(request['page'])
            query['start']  = query['rows']*page
            #if pin_count < query['rows']*page:
            #    return ''
        
        board_data = board.solr(query)
        print len(board_data)

        boards_dict = board.formatBoards(board_data)
        
        if request:
            #print request
            callback_result = {
                            'filter':'board:index',
                            'boards':boards_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:
            boards = ''            
            for _board_t in boards_dict:                
                boards = self.render_string('board_unit.html',board=_board_t) + boards
            
            self.render('board_pop.html',user=self.currentUserInfo(),boards=boards)