[Greater-commits] r3622 - trunk/GREAT-ER-DB/GreaterDB
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Jul 20 14:52:22 CEST 2011
Author: aheinecke
Date: 2011-07-20 14:52:22 +0200 (Wed, 20 Jul 2011)
New Revision: 3622
Modified:
trunk/GREAT-ER-DB/GreaterDB/interface.py
Log:
Since we use GREATER with unicode/utf-8 and handle everyhing internally
in unicode make the database object representation also utf-8
this fixes several issues where utf-8 encoded strings in the database
would not be correctly encoded in GREAT-ER's python objects
Modified: trunk/GREAT-ER-DB/GreaterDB/interface.py
===================================================================
--- trunk/GREAT-ER-DB/GreaterDB/interface.py 2011-07-20 12:50:47 UTC (rev 3621)
+++ trunk/GREAT-ER-DB/GreaterDB/interface.py 2011-07-20 12:52:22 UTC (rev 3622)
@@ -77,6 +77,11 @@
This method should only be used by the database functions.
"""
+ for key in fields:
+ if key == "file_obj": continue
+ if isinstance(fields[key], basestring):
+ if not isinstance(fields[key], unicode):
+ fields[key] = unicode(fields[key], 'utf-8')
self.__dict__["_fields"] = fields
self._modified = 0
self._new = 0
@@ -106,6 +111,10 @@
# override attribute access to refer to the fields dictionary for
# attributes with names of fields.
def __setattr__(self, attr, value):
+ if isinstance(value, basestring) and not attr == "file_obj":
+ if not isinstance(value, unicode):
+ value = unicode(value, 'utf-8')
+
if self._fields.has_key(attr):
old = self._fields[attr]
self._fields[attr] = value
More information about the Greater-commits
mailing list