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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jan 29 15:17:59 CET 2010


Author: bh
Date: 2010-01-29 15:17:58 +0100 (Fri, 29 Jan 2010)
New Revision: 1015

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/helpers.py
   wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (ensure_unicode),
waskaweb/lib/helpers.py (ensure_unicode): Move ensure_unicode from
case to helpers to make it available to other parts of the code.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-29 14:15:03 UTC (rev 1014)
+++ wasko/branches/2.0/ChangeLog	2010-01-29 14:17:58 UTC (rev 1015)
@@ -1,5 +1,11 @@
 2010-01-29  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/model/case.py (ensure_unicode),
+	waskaweb/lib/helpers.py (ensure_unicode): Move ensure_unicode from
+	case to helpers to make it available to other parts of the code.
+
+2010-01-29  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/model/user.py: Remove unused imports.
 
 2010-01-29  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/waskaweb/lib/helpers.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/helpers.py	2010-01-29 14:15:03 UTC (rev 1014)
+++ wasko/branches/2.0/waskaweb/lib/helpers.py	2010-01-29 14:17:58 UTC (rev 1015)
@@ -52,6 +52,18 @@
 
 log = logging.getLogger(__name__)
 
+
+# unicode helper
+def ensure_unicode(s):
+    """Convert s to a unicode object.
+    If it's alredy a unicode object, s is returned as is.  Otherwise
+    it's converted to a byte-string which is assumed to be in utf-8 and
+    then converted to unicode."""
+    if isinstance(s, unicode):
+        return s
+    return unicode(str(s), 'utf-8')
+
+
 # Helper functions used in the UI to show some information like status messages
 # or icons
 

Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py	2010-01-29 14:15:03 UTC (rev 1014)
+++ wasko/branches/2.0/waskaweb/model/case.py	2010-01-29 14:17:58 UTC (rev 1015)
@@ -45,7 +45,7 @@
 from formed.meta.data import RepeatNode
 
 from waskaweb.lib.base import session, g
-from waskaweb.lib.helpers import dd_mm_YYYY
+from waskaweb.lib.helpers import dd_mm_YYYY, ensure_unicode
 from waskaweb.lib.db import db, PostgresDBInterface
 from waskaweb.lib.search import CaseSearch
 #from waskaweb.lib.csv import exportAsCSV
@@ -67,16 +67,6 @@
 log = logging.getLogger(__name__)
 
 
-def ensure_unicode(s):
-    """Convert s to a unicode object.
-    If it's alredy a unicode object, s is returned as is.  Otherwise
-    it's converted to a byte-string which is assumed to be in utf-8 and
-    then converted to unicode."""
-    if isinstance(s, unicode):
-        return s
-    return unicode(str(s), 'utf-8')
-
-
 def get_field_identifier(id, name, it=None, idx=0):
     """Will return the identifier of a field. If the field in in a rg the
     identifier of the first occourance will be returned on default."""



More information about the Mpuls-commits mailing list