當前位置: 首頁>>代碼示例>>Python>>正文


Python Board.get方法代碼示例

本文整理匯總了Python中models.board.Board.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Board.get方法的具體用法?Python Board.get怎麽用?Python Board.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.board.Board的用法示例。


在下文中一共展示了Board.get方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_and_get_boards

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
    def test_add_and_get_boards(self):
        cid = User.add("test_user1", "password", "[email protected]")
        user = User.get(cid)

        bid0 = Board.add("board1", "A")
        bid1 = Board.add("board2", "A")
        board0 = Board.get(bid0)
        board1 = Board.get(bid1)
        user.add_board(board0)

        assert str(bid0) in user.get_board_ids()
        assert str(bid1) not in user.get_board_ids()
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:14,代碼來源:test_user.py

示例2: get

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def get(self,key):        
     res = {}         
     user_key = self.get_secure_cookie("user_key")
     b_key = "%s%s" % (user_key,key)
     
     boardFollow = BoardFollow()
     
     if boardFollow.get(b_key):
         res['code'] = 1
         res['msg'] = "您已關注過了"
     else:
         board = Board()
         board.key = key
         board.data =  board.get(key)
         board.data['follow'] = int(board.data['follow']) + 1
         board.put()            
         boardFollow.key = b_key
         
         boardFollow.data['user'] = user_key
         boardFollow.data['board'] = key
         boardFollow.data['createTime'] = int(time.time())
         boardFollow.post()
         res['code'] = 0
         res['msg'] = "成功"
         print res                
     res_str = json.dumps(res)
     self.write(res_str)
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:29,代碼來源:board.py

示例3: test_add_and_get_lists

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
    def test_add_and_get_lists(self):
        bid0 = Board.add("board0", "A")
        board0 = Board.get(bid0)
        bid1 = Board.add("board1", "A")

        lid0 = List.add("list0", bid0)
        lid1 = List.add("list1", bid1)
        assert lid0 in [_list.id for _list in board0.get_lists()]
        assert lid1 not in [_list.id for _list in board0.get_lists()]
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:11,代碼來源:test_board.py

示例4: test_add_and_get_users

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def test_add_and_get_users(self):
     bid0 = Board.add("board0", "A")
     board0 = Board.get(bid0)
     uid0 = User.add("test1", "password", "[email protected]")
     user0 = User.get(uid0)
     uid1 = User.add("test2", "password", "[email protected]")
     user1 = User.get(uid0)
     board0.add_user(user0)
     assert str(uid0) in board0.get_user_ids()
     assert str(uid1) not in board0.get_user_ids()
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:12,代碼來源:test_board.py

示例5: post

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def post(self,id):
     import hashlib     
     key          = self.get_argument("key",None)
     title        = self.get_argument("title",None)
     
     user_key     = self.get_argument("user",None)
     category_key = self.get_argument("category",None)
             
     _tmp = "%s%s" % (user_key,title)        
     
     board                  = Board()
     user                  = User()
     user_data = user.get(user_key)
     nickname  = user_data['nickname']
     import time
     if key:            
         board.key              = key
         board.data             = board.get(key)
         board.data['user']     = user_key                
         board.data['category'] = category_key
         board.data['title']    = title 
         board.data['createTime']    = time.time() 
         board.data['key']      = key 
         print board.data            
         board.put()
     else:                               
         data = board.get(board.key)
         if data:
             print "exist"
         else:       
             board.key              = board.genKey(_tmp)
             board.data['user']     = user_key                
             board.data['category'] = category_key
             board.data['title']    = title   
             board.data['createTime']    = time.time() 
             board.data['key']      = board.key     
             board.data['pins']    = []      
             board.post()
             
     self.redirect('/manager/board/')
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:42,代碼來源:board.py

示例6: api_board

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
def api_board(board_id=None):
    print "=======", request.form
    try:
        title = request.form['title']
    except:
        return jsonify({'code':400, 'message':'Invalid Request'})

    board_id = Board.add(title,'A')
    board = Board.get(board_id)
    board.add_user(current_user)
    current_user.add_board(board)
    List.add("To Do", board_id)
    List.add("Doing", board_id)
    List.add("Done", board_id)
    return jsonify({'board_id':board_id})
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:17,代碼來源:views.py

示例7: post

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def post(self):
     import time        
     board_key    = self.get_argument("board",None)
     pic_url      = self.get_argument("pic_url",None)
     thumb_url    = self.get_argument("thumb_url",None)
     content      = self.get_argument("content",None)        
     
     pin       = Pin()
     thumb     = Thumb()
     pic       = Pic()
     board     = Board()
     
     board.data  =board.get(board_key)
     
     user_key = self.get_secure_cookie('user_key')
     
     _tmp = "%s%s" % (content,user_key)
     pin_key = pin.genKey(_tmp)
     
     if pin_key not in board.data['pins']:
         board.data['pins'].append(pin_key)
     board.key      = board.data['key']
     
     pin.key = pin_key
     
     pin.data['rawtext'] = content
     pin.data['user']    = user_key
     pin.data['board']   = board_key
     pin.data['category']   = board.data['category']
     pin.data['createTime'] = int(time.time())
     
     pic.key = pin_key
     pic.data['url'] = pic_url
     
     thumb.key = pin_key
     thumb.data['url'] = thumb_url
     
     try:
         board.put()
         pin.post()
         pic.post()
         thumb.post()
                   
     except Exception as what:
         print what
         self.write(what)
     else:
         self.redirect('/mark/%s/' % pin_key)   
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:50,代碼來源:service.py

示例8: api_check_string_match

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
def api_check_string_match():
    try:
        user_input = request.args.get('input')
        board_id = request.args.get('board_id')
    except KeyError:
        return jsonify({'code': 400, 'message': 'Bad Request'})
    print "input: " + user_input
    match_user = User.get_whole_match(user_input)
    if match_user == -1:    #has no results queried out
        return jsonify({'code': 200, 'find_status': "NO USER"})
    else:
        board_obj = Board.get(board_id)
        board_obj.add_user(match_user)    #add the user to board
        match_user.add_board(board_obj)   #add the board to user

        return jsonify({'code': 200, 'find_status' : match_user.id})
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:18,代碼來源:views.py

示例9: formatBoards

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def formatBoards(self,board_data):
     data = []
     boardModel = Board()
     for board in board_data:
         #print "******************"
         _board = {}
         _board =  boardModel.get(board['board'])  
             
         _board['pin_pics'] = []
         board_pins_max = 9
         i = 0
         for pin_key in _board['pins']:
             thumb = Thumb()                
             thumb.data = thumb.get(pin_key)
             #print thumb.data
             i = i + 1
             if i <= board_pins_max and thumb.data:                
                 _board['pin_pics'].append(thumb.data['url'])    
         data.append(_board)      
     return data   
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:22,代碼來源:boardFollow.py

示例10: render_board

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
def render_board(board_id = None):
    '''board page'''
    board=Board.get(board_id)
    activity = Activity.get_all(board_id)
    try:
        show_card_id = request.args['show_card']
    except:
        show_card_id = -1

    if board == None:
        return render_template('404.html');
    else:
        return render_template('board.html', 
                                user=current_user, 
                                board=board, 
                                show_card_id=show_card_id,
                                lists = board.get_lists(),
                                activities = activity,
                                add_card_form = AddCardForm(),
                                add_list_form = AddListForm(),
                                edit_card_desc_form = EditCardDescForm(),
                                add_comment_form = AddCommentForm(),
                                add_board_form = AddBoardForm())
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:25,代碼來源:views.py

示例11: get

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def get(self,key):
     uri = self.request.uri
     request = {}
     pin = Pin()
     
     pin_keys = pin.getByKeyValues("user",key)
     pin_count = len(pin_keys)
     
     query = {}
     query['q']         = "user:%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)
     marks_dict = pin.formatPins(pin_data)    
     
     if request:
         #print request
         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:
         board = Board()
         user = User()
         marks = ''
         for _mark_t in marks_dict:
             marks = self.render_string('mark.html',mark=_mark_t)+marks
         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_pins.html',counts=counts,u_user=u_user,user=self.currentUserInfo(),board = board.get(key),marks=marks)
開發者ID:aviatorBeijing,項目名稱:ptpy,代碼行數:51,代碼來源:user.py

示例12: test_set_and_get_board

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
 def test_set_and_get_board(self):
     bid0 = Board.add("board0", "A")
     board0 = Board.get(bid0)
     assert board0.title == "board0", True
     assert board0.visibility == "A", True
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:7,代碼來源:test_board.py

示例13:

# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import get [as 別名]
Card.__table__.drop(mysql_engine, checkfirst=True)
Card.__table__.create(mysql_engine, checkfirst=True)
Comment.__table__.drop(mysql_engine, checkfirst=True)
Comment.__table__.create(mysql_engine, checkfirst=True)
uid0 = User.add("test1", "password", "[email protected]")
uid1 = User.add("test2", "password", "[email protected]")
uid2 = User.add("test3", "password", "[email protected]")

user0 = User.get(uid0)
user1 = User.get(uid1)
user2 = User.get(uid2)

bid0 = Board.add("board1", "A")
bid1 = Board.add("board2", "A")

board0 = Board.get(bid0)
board1 = Board.get(bid1)

board0.add_user(user0)
board0.add_user(user1)
board0.add_user(user2)

board1.add_user(user0)
board1.add_user(user1)

user0.add_board(board0)
user0.add_board(board1)
user1.add_board(board0)
user1.add_board(board1)
user2.add_board(board0)
開發者ID:GuangzheGao,項目名稱:sorbitol,代碼行數:32,代碼來源:test_data.py


注:本文中的models.board.Board.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。