Example #1
0
 def create_pin(self,pin):
     """
     This method returns pin_id on successful pin creation and returns False on unsuccessful attempt
     """
     if pin.user_id in userdb:
         try:
            #store the new pin
            pin_id = self.get_next_id("pin")
            newpin = {"pin_name":pin.pin_name, "user_id":pin.user_id, "pin_url":pin.pin_url, "comments":[]}
            pindb[str(pin_id)] = newpin
            #increment pin count in metadata
            pincount = Counttrack.load(countdb,"pin")
            pincount.count=pin_id
            pincount.store(countdb)
            return str(pin_id)
         except:
             return False
     else:
          return False
Example #2
0
    def create_board(self,board):
        """
        This method returns board_id on successful board creation and returns False on unsuccessful attempt
        """
        if board.user_id in userdb:
            try:
               board_id = self.get_next_id("board")
               newboard = {"board_name":board.board_name, "user_id":board.user_id, "pins":[], "board_type":"public"}
               boarddb[str(board_id)] = newboard

               #increment board count in metadata
               boardcount = Counttrack.load(countdb,"board")
               boardcount.count=board_id
               boardcount.store(countdb)
               return str(board_id)
            except:
                return False
        else:
            return False
Example #3
0
    def insert_registration(self, user):
        """
        This method returns user_id on successful registration or False on unsuccessful attempt
        """
        try:
            user_id= self.get_next_id("user")
            #check if user already exists
            for iad in userdb:
                print "user.username",user.username
                if (userdb[iad].get('username') == user.username):
                    return False

            #store new user
            newuser = {'name': user.name, 'username':user.username, 'password':user.password}
            userdb[str(user_id)]=newuser

            #update user count
            usercount = Counttrack.load(countdb,"user")
            usercount.count=user_id
            usercount.store(countdb)

            return user_id
        except:
            return False
Example #4
0
 def get_next_id(self, entity):
     countobj = Counttrack.load(countdb,entity)
     if not(countobj is None):
         return countobj.count+1
     else:
         return 0