comparison src/memory/sqlite.py @ 839:f8681a7fd834

memory (sqlite): the result of pickle.dumps in addToHistory must be encoded for the special characters to be stored.
author souliane <souliane@mailoo.org>
date Wed, 12 Feb 2014 21:46:48 +0100
parents 1fe00f0c9a91
children c2f6ada7858f
comparison
equal deleted inserted replaced
838:8829a6c0b070 839:f8681a7fd834
188 @param timestamp: timestamp in seconds since epoch, or None to use current time 188 @param timestamp: timestamp in seconds since epoch, or None to use current time
189 """ 189 """
190 assert(profile) 190 assert(profile)
191 if extra is None: 191 if extra is None:
192 extra = {} 192 extra = {}
193 extra_ = pickle.dumps({k: v.encode('utf-8') for k, v in extra.items()}, 0).decode('utf-8')
193 d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?)", 194 d = self.dbpool.runQuery("INSERT INTO history(source, source_res, dest, dest_res, timestamp, message, type, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?)",
194 (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time(), 195 (from_jid.userhost(), from_jid.resource, to_jid.userhost(), to_jid.resource, timestamp or time(),
195 message, _type, pickle.dumps(extra, 0), self.profiles[profile])) 196 message, _type, extra_, self.profiles[profile]))
196 d.addErrback(lambda ignore: error(_("Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" % 197 d.addErrback(lambda ignore: error(_("Can't save following message in history: from [%(from_jid)s] to [%(to_jid)s] ==> [%(message)s]" %
197 {"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message}))) 198 {"from_jid": from_jid.full(), "to_jid": to_jid.full(), "message": message})))
198 return d 199 return d
199 200
200 def getHistory(self, from_jid, to_jid, limit=0, between=True, profile=None): 201 def getHistory(self, from_jid, to_jid, limit=0, between=True, profile=None):