示例#1
0
文件: util.py 项目: cklzqw/gaeaib
def get_threads(board, page=0, fmt_name="page"):

  _fmt = "thread_" + fmt_name
  if _fmt in globals():
    fmt = globals()[_fmt]
  else:
    fmt = thread_plain

  threads = Board.load(board)
  threads = threads[THREAD_PER_PAGE*page:THREAD_PER_PAGE*(page+1)]
  logging.info("threadlist in %r : %r" % (board, threads))

  # grab data from cache
  data =  Thread.load_list(threads, board)

  return [ fmt(num,th) for num,th in data if th ]
示例#2
0
 def attach_pin(self,user_id,pin_id,board_id):
     """
     This method returns "pin Attached" on successful operation and False on unsuccessful attempts.
     This method attaches a particular pin with pin_id to a board with board_id
     """
     if board_id in boarddb and user_id in userdb:
         try:
             board=Board.load(boarddb,board_id)
             if board['user_id']==user_id:
                 board.pins.append(pin_id=pin_id)
                 board.store(boarddb)
                 return "Pin Attached"
             else:
                 return False
         except:
             return False
     else:
         return False
示例#3
0
文件: util.py 项目: strogo/gaeaib
def get_threads(board, page=0, fmt_name="page"):

  _fmt = "thread_" + fmt_name
  if _fmt in globals():
    fmt = globals()[_fmt]
  else:
    fmt = thread_plain

  per_page = get_config('aib.ib', 'thread_per_page')

  threads = Board.load(board) or []
  threads = threads[per_page*page:per_page*(page+1)]
  logging.info("threadlist in %r : %r" % (board, threads))

  # grab data from cache
  data =  Thread.load_list(threads, board)

  return [ fmt(num,th) for num,th in data if th ]
示例#4
0
 def get_board(self,board_id):
     """
     Returns All the pins in a particular board with board_id
     """
     try:
         board=Board.load(boarddb,board_id)
         result={}
         result['board_id']=board_id
         result['board_name']=board.board_name
         pins=[]
         for pin_item in board.pins:
             pin2=Pin.load(pindb,pin_item.pin_id)
             pin={}
             pin['pin_id']=pin_item.pin_id
             pin['pin_name']=pin2.pin_name
             pin['pin_url']=request.urlparts.scheme+"://"+request.urlparts.netloc+"/"+pin2.pin_url
             pins.append(pin)
         result['pins']=pins
         return result
     except:
         return False
示例#5
0
文件: api.py 项目: a37912/gaeaib
 def get(self, board):
   return json_response( Board.load(board) )