[hamster-applet] bug 604469 iterating through row keys is another new feature of python2.6



commit 0b7c880466d56badda8d6439975fc09b2c3f0f27
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Dec 14 01:03:31 2009 +0000

    bug 604469  iterating through row keys is another new feature of python2.6

 hamster/db.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/hamster/db.py b/hamster/db.py
index b3f8194..09f36de 100644
--- a/hamster/db.py
+++ b/hamster/db.py
@@ -310,7 +310,16 @@ class Storage(storage.Storage):
         grouped_facts = []
         for fact_id, fact_tags in itertools.groupby(facts, lambda f: f["id"]):
             fact_tags = list(fact_tags)
-            grouped_fact = dict(fact_tags[0]) #first is as good as the last one
+            
+            # first one is as good as the last one
+            grouped_fact = fact_tags[0]
+
+            # we need dict so we can modify it (sqlite.Row is read only)
+            # in python 2.5, sqlite does not have keys() yet, so we hardcode them (yay!)
+            keys = ["id", "start_time", "end_time", "description", "name",
+                    "activity_id", "category", "category_id", "tags"]
+            grouped_fact = dict([(key, grouped_fact[key]) for key in keys])
+            
             grouped_fact["tags"] = [ft["tags"] for ft in fact_tags if ft["tags"]]
             grouped_facts.append(grouped_fact)
         return grouped_facts



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]