Exemple #1
0
 def fetch_pin(self,pin_id):
   """
   Returns a pin corresponding to a particular pin_id
   """
   try:
      pin=Pin.load(pindb,pin_id)
      return pin
   except:
       return "error:pin does not exist"
Exemple #2
0
 def get_pin(self,pin_id):
   """
     Returns Pin item with information of user id,pin id, pin name, pin url and comments
   """
   try:
      pin=Pin.load(pindb,pin_id)
      pin_item={}
      pin_item['pin_id']=pin_id
      pin_item['pin_name']=pin.pin_name
      pin_item['pin_url']=request.urlparts.scheme+"://"+request.urlparts.netloc+"/"+pin.pin_url
      comments=[]
      for comments_item in pin.comments:
          comment={}
          comment['user_id']=comments_item.user_id
          comment['comment']=comments_item.comment
          comments.append(comment)
      pin_item['comments']=comments
      return pin_item
   except:
       return False
Exemple #3
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