Exemple #1
0
 def put(self,dic,number=-1):
     if number == -1: number=self.get_length()
     
     dic["++unique++"]=str(number)
     con = PyTyrant.open("localhost")
     self.__put(dic,str(number),self.header)
     con.close()
Exemple #2
0
 def __put(self,scheme,number,header=""):
     for k,v in scheme.iteritems():
         if type(v)==dict :
             self.__put(v,number,header+"/"+k)
         elif type(v) == str :
             query = header + "/" + k+"_"+number
             con = PyTyrant.open("localhost")
             con[query] = v
             con.close()
Exemple #3
0
 def raw_get(self,where="",number=-1):
     obj = {}
     query = self.header+"/"+where
     con = PyTyrant.open("localhost")
     ret = con.prefix_keys(query)
     for i in sorted(ret):
         if number==-1 or int(i.split("_")[-1]) == number :
             obj[i]=con[i]
     con.close()
     return obj
Exemple #4
0
def lookup(address, host=None):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    user = table[addr]
    table.close()

    if host:
        return user + '@' + host
    else:
        return user
Exemple #5
0
def lookup(address, host=None):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    user = table[addr]
    table.close()

    if host:
        return user + '@' + host
    else:
        return user
Exemple #6
0
 def get(self,where="",number=-1):
     if type(where)==str : where = [where]
     objs=[]
     con = PyTyrant.open("localhost")
     ret = []
     for i in where :
         query = self.header+"/"+i
         ret += con.prefix_keys(query)
     for i in sorted(ret):
         ids=i.split("_")[-1]
         if number==-1 or ids == str(number) :
             item = self.__parse(i,con[i])
             item.update({"ids":ids})
             objs.append(item )
     con.close()
     return sorted(objs)
 def open_connection(self, host, port):
     self.db_conn = PyTyrant.open(host, int(port))
Exemple #8
0
 def delete_all(self):
     con=PyTyrant.open("localhost")
     ret = con.prefix_keys(self.header)
     for i in ret:
         del con[i]
     con.close()
Exemple #9
0
 def get_length(self):
     con = PyTyrant.open("localhost")
     query = self.header+"/"+"++unique++"
     length= len(con.prefix_keys(query))
     con.close()
     return length
 def open_connection(self, host, port):
     self.db_conn = PyTyrant.open(host, int(port))
Exemple #11
0
def delete(address):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    del table[addr]
    table.close()
Exemple #12
0
def store(address, maps_to):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    table[addr] = maps_to
    table.close()
Exemple #13
0
def delete(address):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    del table[addr]
    table.close()
Exemple #14
0
def store(address, maps_to):
    name, addr = parseaddr(address)
    table = PyTyrant.open()
    table[addr] = maps_to
    table.close()