Esempio n. 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)
Esempio n. 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
Esempio n. 3
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
Esempio n. 4
0
 def createBins_general(self,bin_name,values,types,num):
     print 'DEBUG: In createBins_general for length:',num
     bins = cl.cl_bin_arr(num)
     print 'DEBUG Bins array created'
     for i in xrange(num):
         print 'DEBUG: creating bin for index: ',i
         b = bins[i]
         print 'DEBUG: bin name: ',bin_name[i] , ' value: ',values[i] , ' type: ',types[i]
         b.bin_name = bin_name[i]
         print 'DEBUG: bin name: ',bin_name[i] , ' value: ',values[i] , ' type: ',types[i]
         if types[i] == "string":
             cl.citrusleaf_object_init_str(b.object, values[i]);
             print 'DEBUG: string bin created'
         elif types[i] == "int":
             cl.citrusleaf_object_init_int(b.object, values[i]);
             print 'DEBUG: int bin created'
         else:
             print 'Wrong Type, use type as "string" or "int"'
         bins[i] = b
     return bins
Esempio n. 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"
Esempio n. 6
0
# Declaring an array in this interface
bins = cl.cl_bin_arr(3)
cans = cl.cl_bin_arr(4)
tins = cl.cl_bin_arr(4)

# Provide values for those bins and then initialize them.
# Initializing bin of type string
b0 = bins[0]
b0.bin_name = "email"
cl.citrusleaf_object_init_str(b0.object, "*****@*****.**");

# Initializing bin of type int
b1 = bins[1]
b1.bin_name = "hits"
cl.citrusleaf_object_init_int(b1.object, 314);


c0 = cans[0]
c0.bin_name = "name"
cl.citrusleaf_object_init_str(c0.object, "Rajiv");

c1 = cans[1]
c1.bin_name = "username"
cl.citrusleaf_object_init_str(c1.object, "rajiv");

c2 = cans[2]
c2.bin_name = "password"
cl.citrusleaf_object_init_str(c2.object, "password");

pin_id=1
Esempio n. 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);