From b30f807885e01e56020cfd55b4133c7a3845b7d7 Mon Sep 17 00:00:00 2001
From: Arnaud Fontaine <arnau@debian.org>
Date: Sat, 7 Feb 2009 15:17:28 +0000
Subject: [PATCH] Let sqlalchemy handle unicode conversion

---
 lib/comments.py |    2 +-
 lib/core.py     |    2 +-
 lib/pyoto.py    |    3 ++-
 lib/sqlinfo.py  |    2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/comments.py b/lib/comments.py
index 50a1d2c..95b572f 100644
--- a/lib/comments.py
+++ b/lib/comments.py
@@ -72,7 +72,7 @@ class CommentAware(object):
                                           time.localtime(row["timestamp"])),
                     "email": row["email"],
                     "registered": row["name"] == row["login"] and "registered" or "",
-                    "body": unicode(row["comment"], 'utf-8') }
+                    "body": row["comment"] }
             results.append(res)
         return results
 
diff --git a/lib/core.py b/lib/core.py
index 8943f3d..060afa3 100644
--- a/lib/core.py
+++ b/lib/core.py
@@ -301,7 +301,7 @@ class PyotoCore(security.SecurityAware, admin.AdminSupport):
             if value == key:
                 attrs["selected"] = "selected"
             yield { "key": key,
-                    "name": unicode(name, "utf-8"),
+                    "name": name,
                     "attrs": attrs }
 
     #
diff --git a/lib/pyoto.py b/lib/pyoto.py
index 7bb007b..67b483a 100644
--- a/lib/pyoto.py
+++ b/lib/pyoto.py
@@ -109,7 +109,8 @@ class PyotoRoot(PyotoDirectory):
         Setup SQL database
         """
         self.sql_engine = sqlalchemy.create_engine(self.config["sql"],
-                                                   echo = False)
+                                                   echo = False,
+                                                   convert_unicode = True)
         metadata.create_all(self.sql_engine)
         metadata.bind = self.sql_engine
         translator.load_map()
diff --git a/lib/sqlinfo.py b/lib/sqlinfo.py
index f7e8e6e..f6c7025 100644
--- a/lib/sqlinfo.py
+++ b/lib/sqlinfo.py
@@ -152,7 +152,7 @@ class Translator(object):
         row = rows.fetchone()
         if not row:
             return None
-        return unicode(row["value"], "utf-8")
+        return row["value"]
     
     def resolve(self, lang):
         """
-- 
1.6.0.6


