comparison src/memory/sqlite.py @ 436:5e9d28ca5109

core: sqlite persistentBinaryDict storage fix
author Goffi <goffi@goffi.org>
date Wed, 30 Nov 2011 00:23:50 +0100
parents 31e8c48b5f5d
children a6640bb8ee95
comparison
equal deleted inserted replaced
435:c243f4cb2ad9 436:5e9d28ca5109
300 @param namespace: namespace of the values 300 @param namespace: namespace of the values
301 @return: deferred""" 301 @return: deferred"""
302 def fillPrivates(result): 302 def fillPrivates(result):
303 for private in result: 303 for private in result:
304 key,value = private 304 key,value = private
305 private_gen[key] = pickle.loads(value,0) 305 private_gen[key] = pickle.loads(str(value))
306 debug(_("loading general private binary values [namespace: %s] from database") % (namespace,)) 306 debug(_("loading general private binary values [namespace: %s] from database") % (namespace,))
307 d = self.dbpool.runQuery("SELECT key,value FROM private_gen_bin WHERE namespace=?", namespace).addCallback(fillPrivates) 307 d = self.dbpool.runQuery("SELECT key,value FROM private_gen_bin WHERE namespace=?", (namespace,)).addCallback(fillPrivates)
308 return d.addErrback(lambda x: debug(_("No binary data present in database for namespace %s") % namespace)) 308 return d.addErrback(lambda x: debug(_("No binary data present in database for namespace %s") % namespace))
309 309
310 def loadIndPrivatesBinary(self, private_ind, namespace, profile): 310 def loadIndPrivatesBinary(self, private_ind, namespace, profile):
311 """Load individual private binary values 311 """Load individual private binary values
312 @param privates_ind: dictionary to fill 312 @param privates_ind: dictionary to fill
314 @param profile: a profile which *must* exist 314 @param profile: a profile which *must* exist
315 @return: deferred""" 315 @return: deferred"""
316 def fillPrivates(result): 316 def fillPrivates(result):
317 for private in result: 317 for private in result:
318 key,value = private 318 key,value = private
319 private_ind[key] = pickle.loads(value,0) 319 private_ind[key] = pickle.loads(str(value))
320 debug(_("loading individual private binary values [namespace: %s] from database") % (namespace,)) 320 debug(_("loading individual private binary values [namespace: %s] from database") % (namespace,))
321 d = self.dbpool.runQuery("SELECT key,value FROM private_ind_bin WHERE namespace=? AND profile_id=?", (namespace, self.profiles[profile])) 321 d = self.dbpool.runQuery("SELECT key,value FROM private_ind_bin WHERE namespace=? AND profile_id=?", (namespace, self.profiles[profile]))
322 d.addCallback(fillPrivates) 322 d.addCallback(fillPrivates)
323 return d.addErrback(lambda x: debug(_("No binary data present in database for namespace %s") % namespace)) 323 return d.addErrback(lambda x: debug(_("No binary data present in database for namespace %s") % namespace))
324 324