Esempio n. 1
0
 def setValues(self, user, dbName, key, value):
     key = encodingTools.decodeToUnicode(key)
     #print 'setting:',value,type(value)
     if not (type(value) == list):
         value = [value]
     uniValue = []
     for i in value:
         uniValue.append(encodingTools.decodeToUnicode(i))
     self.getDb(user, dbName)[key] = uniValue
     self.cache[(user, dbName,key)] = uniValue
Esempio n. 2
0
 def getSnapshotValueRange(self, key, timestamp, start, cnt):
     res = self.proxy.getSnapshotValueRange(self.user, self.dbName, key, timestamp, start, cnt)
     uniRes = []
     #print '++++++++++++++++++++++++++++++++++++++++++++'
     #print res
     for i in res:
         uniRes.append(encodingTools.decodeToUnicode(i))
     return uniRes
Esempio n. 3
0
 def appendValues(self, user, dbName, key, value):
     '''
     This value will be called in info collection from infoDb
     '''
     key = encodingTools.decodeToUnicode(key)
     #print 'appending:',value,type(value)
     if not (type(value) == list):
         value = [value]
     uniValue = []
     for i in value:
         uniValue.append(encodingTools.decodeToUnicode(i))
     self.getDb(user, dbName).append(key, uniValue)
     try:
         #Invliad the item
         del self.cache[(user, dbName,key)]
     except KeyError:
         pass
Esempio n. 4
0
 def bulkAdd(self, user, dbName, bulkDict):
     '''
     This function is used in jstreeOnCollectionV2
     '''
     #print 'entering bulk add'
     encDict = {}
     for i in bulkDict:
         value = bulkDict[i]
         if not (type(value) == list):
             value = [value]
         encValueList = []
         for j in value:
             print 'adding value:', i, j
             encValueList.append(encodingTools.decodeToUnicode(j))
         encDict[encodingTools.decodeToUnicode(i)] = encValueList
         try:
             #Invliad the item
             del self.cache[(user, dbName, encodingTools.decodeToUnicode(i))]
         except KeyError:
             pass
     self.getDb(user, dbName).bulkAdd(encDict)
Esempio n. 5
0
 def __getitem__(self, key):
     if type(key) != unicode:
         raise nonUnicode
     res = self.proxy.getValues(self.user, self.dbName, key)
     if res is None:
         raise KeyError
     if type(res) != list:
         raise 'non list'
     #print res
     uniRes = []
     for i in res:
         uniRes.append(encodingTools.decodeToUnicode(i))
     return uniRes
Esempio n. 6
0
 def getValues(self, user, dbName, key):
     #print type(key)
     key = encodingTools.decodeToUnicode(key)
     #print key, type(key)
     #print 'getValue:',user, dbName, key
     try:
         return self.cache[(user, dbName,key)]
     except KeyError:
         pass
     try:
         res = self.getDb(user, dbName)[key]
         self.cache[(user, dbName,key)] = res
         #print 'return get:', user, dbName, key, res
         return res
     except KeyError:
         #print 'no item, return None so client will raise exception'
         return None
Esempio n. 7
0
 def getSnapshotValueRange(self, user, dbName, key, timestamp, start, cnt):
     key = encodingTools.decodeToUnicode(key)
     res = self.getDb(user, dbName).getSnapshotValueRange(key, timestamp, start, cnt)
     #print res
     return res