Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSayamindu Dasgupta <sayamindu@gmail.com>2009-08-05 10:38:21 (GMT)
committer Sayamindu Dasgupta <sayamindu@gmail.com>2009-08-05 10:38:21 (GMT)
commit851a69a1fdb9cfb440369a0f8746e131c678d0bc (patch)
tree7003e19fd7f24424ca22a4c7f6d1bc6b4c557d5d
parent76283f7761813fb09502e526a89e6bdbda28e91b (diff)
Fix encoding b0rkage while retrieving stuff from sqlite db
-rw-r--r--readdb.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/readdb.py b/readdb.py
index c7d290a..c24a664 100644
--- a/readdb.py
+++ b/readdb.py
@@ -41,11 +41,13 @@ class BookmarkManager:
shutil.copy(srcpath, dbpath)
self._conn = sqlite3.connect(dbpath)
+ self._conn.text_factory = lambda x: unicode(x, "utf-8", "ignore")
+
self._bookmarks = []
self._populate_bookmarks()
- def add_bookmark(self, page, title, local=1):
+ def add_bookmark(self, page, content, local=1):
# locale = 0 means that this is a bookmark originally
# created by the person who originally shared the file
timestamp = time.time()
@@ -53,7 +55,8 @@ class BookmarkManager:
user = client.get_string("/desktop/sugar/user/nick")
color = client.get_string("/desktop/sugar/user/color")
- t = (self._filehash, page, title, timestamp, user, color, local)
+ #XXX: the field for content is called title for compatibility reasons
+ t = (self._filehash, page, content, timestamp, user, color, local)
self._conn.execute('insert into bookmarks values (?, ?, ?, ?, ?, ?, ?)', t)
self._conn.commit()