[Mpuls-commits] r1044 - in wasko/branches/2.0: . waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 1 11:36:58 CET 2010


Author: bh
Date: 2010-02-01 11:36:56 +0100 (Mon, 01 Feb 2010)
New Revision: 1044

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/db.py
Log:
* waskaweb/lib/db.py: Make psycopg2 return unicode objects in
query results so that they don't have to be converted explicitly
later.  Also, the since the formed instance tree uses this, it now
contains unicode objects too.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-01 10:35:24 UTC (rev 1043)
+++ wasko/branches/2.0/ChangeLog	2010-02-01 10:36:56 UTC (rev 1044)
@@ -1,5 +1,12 @@
 2010-02-01  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/db.py: Make psycopg2 return unicode objects in
+	query results so that they don't have to be converted explicitly
+	later.  Also, the since the formed instance tree uses this, it now
+	contains unicode objects too.
+
+2010-02-01  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/model/agencysettings.py (Agency._fetchData): Use
 	ensure_unicode to convert the values to unicode immediately when
 	read from the database.

Modified: wasko/branches/2.0/waskaweb/lib/db.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/db.py	2010-02-01 10:35:24 UTC (rev 1043)
+++ wasko/branches/2.0/waskaweb/lib/db.py	2010-02-01 10:36:56 UTC (rev 1044)
@@ -32,6 +32,7 @@
 import logging
 
 import psycopg2 as dbapi
+import psycopg2.extensions
 
 from paste.registry import StackedObjectProxy
 
@@ -39,6 +40,13 @@
 log = logging.getLogger(__name__)
 
 
+# Make psycopg2 return unicode objects for strings in query results.
+# This is probably not the best way to deal with unicode and the DB-API.
+# In particular, it's obviously not directly portable to other DB-API
+# implementations.
+psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
+
+
 db = StackedObjectProxy(name="waska.db")
 
 



More information about the Mpuls-commits mailing list