Пример #1
0
    def setComment(self, uId, pId, c):
        print "----> User ", uId," commenting ", c["comment"], " on pin ", pId
        comment_count = self.getCount("comment_count")
        comment_count +=1
        print "1"
        comment_string = str(c["comment"])
        
        user_id = int(uId)
        pin_id = int(pId)
        print "2"
        
        cl.citrusleaf_object_init_str(c0.object, comment_string)#str(u["name"]));
        cl.citrusleaf_object_init_int(c1.object, pin_id)
        cl.citrusleaf_object_init_int(c2.object, user_id)

        print "user id : ", user_id
        # Assign the structure back to the "bins" variable
        comment[0] = c0
        comment[1] = c1
        comment[2] = c2
                
        print "name ",c["comment"]
        print "reading from object " , comment[0].object.u.str
        return_value = cl.citrusleaf_put(clu, "comment", str(comment_count), key_obj, comment, 3, None);
        self.setCount("comment_count", comment_count)
        
        return self.getPin(pin_id)
Пример #2
0
    def createBoard(self,user_id,b, pin_list=""):
        print "---> creating board:",b
        
        board_count = self.getCount("board_count")
        board_count +=1
        print "1"
        board_name = str(b["boardname"])
        
        user_id = int(user_id)
        print "2"
        cl.citrusleaf_object_init_str(b0.object, board_name)#str(u["name"]));
        cl.citrusleaf_object_init_str(b1.object, pin_list)
        cl.citrusleaf_object_init_int(b2.object, user_id)

        print "user id : ", user_id
        # Assign the structure back to the "bins" variable
        board[0] = b0
        board[1] = b1
        board[2] = b2
                
        print "name ",b["boardname"]
        print "reading from object " , board[0].object.u.str
        return_value = cl.citrusleaf_put(clu, "board", str(board_count), key_obj, board, 3, None);
        self.setCount("board_count", board_count)
        return board_count
Пример #3
0
 def createUser(self, u, user_count):
     name = str(u["name"])
     uname = str(u["username"])
     passwd = str (u["password"])
     print
     cl.citrusleaf_object_init_str(u0.object, name)#str(u["name"]));
     cl.citrusleaf_object_init_str(u1.object, uname)#str(u["username"]));
     cl.citrusleaf_object_init_str(u2.object, passwd)#str(u["password"]));
     print uname, name, passwd
     # Assign the structure back to the "bins" variable
     user[0] = u0
     user[1] = u1
     user[2] = u2
     print "name ",u["name"]
     print "reading from object " , user[0].object.u.str
     return_value = cl.citrusleaf_put(clu, "user", str(user_count), key_obj, user, 3, None);
Пример #4
0
    def createPin(self, user_id, pname, img):
        print "---> creating pin:",pname
        pin_count = self.getCount("pin_count")
        pin_count +=1
        print "1"
        pin_name = pname
        pin_path = str(img.filename)
        print pin_name, pin_path
        user_id = int(user_id)
        print "2"

        dir = '/home/rajiv/workspace/python/cmpe273-project2/'+str(user_id)
        print dir

        if not os.path.exists(dir):
            os.mkdir(dir)
        fname = str(datetime.datetime.now())+'_'+str(img.filename)
        filepath = dir + '/'+fname
        imageUrl = 'http://localhost:8080'+str(user_id)+fname
        
        img.save(filepath)
        print(imageUrl)
        
        cl.citrusleaf_object_init_str(p0.object, pin_name)#str(u["name"]));
        cl.citrusleaf_object_init_str(p1.object, filepath)
        cl.citrusleaf_object_init_int(p2.object, user_id)
        #img = zlib.compress(img)
        print "here"
        #cl.citrusleaf_object_init_blob(p3.object, img, "102400")
        print "here too"
        

        print "user id : ", user_id
        # Assign the structure back to the "bins" variable
        pin[0] = p0
        pin[1] = p1
        pin[2] = p2
        #pin[3] = p3
                
        print "name ",pin_name
        print "reading from object " , pin[0].object.u.str
        return_value = cl.citrusleaf_put(clu, "pin", str(pin_count), key_obj, pin, 3, None);
        self.setCount("pin_count", pin_count)
        return pin_count
Пример #5
0
 def updateBoard(self, user_id, board_id, pin):
     print "--> updating board:",board_id
     rv = cl.citrusleaf_get_all(clu, "board", str(board_id), key_obj, bins_get_all , size, 100, generation);
     number_bins = cl.intp_value(size)
     # Use helper function get_bins to get the bins from pointer bins_get_all and the number of bins
     if number_bins > 0 : 
         bins = pcl.get_bins (bins_get_all, number_bins)
         for i in xrange(number_bins):
             if ((bins[i].object.type)==cl.CL_STR) & (bins[i].bin_name == "pin_list"):
                 pin_list = bins[i].object.u.str
 
             if ((bins[i].object.type)==cl.CL_STR) & (bins[i].bin_name == "board_name"):
                 board_name = bins[i].object.u.str
             
         print pin_list,board_name        
         print "Pin List : ", pin_list
         if (pin_list == "") :
             pin_list = pin["pin_id"]
         else :
             pin_list = str(pin_list)+","+str(pin["pin_id"]) 
         print "Updated pin list : ", pin_list
         b = {"boardname": board_name}
         print b
         #self.createBoard(user_id, b, pin_list)
         user_id = int(user_id)
         pin_list = str(pin_list)
         cl.citrusleaf_object_init_str(b1.object, pin_list)
         cl.citrusleaf_object_init_str(b0.object, board_name)#str(u["name"]));
         cl.citrusleaf_object_init_int(b2.object, user_id)
         # Assign the structure back to the "bins" variable
         board[0] = b0
         board[1] = b1
         board[2] = b2
         
         return_value = cl.citrusleaf_put(clu, "board", str(board_id), key_obj, board, 3, None);
         print "here"
         return b
     return "error"
Пример #6
0
 def writeToDB(self,set_name,key_obj,bins,num):
     print 'DEBUG: In writeToDB',num
     return_value = cl.citrusleaf_put(self.asc, "test", set_name, key_obj, bins, num, None);
     if return_value != cl.CITRUSLEAF_OK :
         print "Failure setting values %dn", return_value
         sys.exit(-1);
Пример #7
0
 def setCount(self,name,value):
     cl.citrusleaf_object_init_int(count0.object, value);
     count[0] = count0
     print name,value
     return_value = cl.citrusleaf_put(clu, "count", name, key_obj, count, 1, None);