--- MPIWGWeb/MPIWGProjects.py 2007/07/02 15:50:22 1.47.2.78
+++ MPIWGWeb/MPIWGProjects.py 2007/10/18 12:00:17 1.47.2.79
@@ -110,6 +110,29 @@ def sortI(x,y):
except:
return cmp(x[1],y[1])
+
+def unicodify(str):
+ """decode str (utf-8 or latin-1 representation) into unicode object"""
+ if not str:
+ return ""
+ if type(str) is StringType:
+ try:
+ return str.decode('utf-8')
+ except:
+ return str.decode('latin-1')
+ else:
+ return str
+
+def utf8ify(str):
+ """encode unicode object or string into byte string in utf-8 representation"""
+ if not str:
+ return ""
+ if type(str) is StringType:
+ return str
+ else:
+ return str.encode('utf-8')
+
+
class MPIWGLink(SimpleItem):
"""create a symbolic link to another page"""
@@ -1594,6 +1617,9 @@ class MPIWGProject(CatalogAware,Folder):
meta_type='MPIWGProject'
default_catalog='ProjectCatalog'
+ def decode(self,str):
+ """return unicode object"""
+ return unicodify(str)
def sortedByPlace(self,metatype):
"""find metatype and sort by place"""
@@ -2280,7 +2306,10 @@ class MPIWGProject(CatalogAware,Folder):
if (text5=="
") or (text5=="
"):
text5=""
- return text5.encode('utf-8')
+ logging.debug("getcontent: field=%s filter=%s -> %s"%(field,filter,repr(text5)))
+ #return unicodify(text5)
+ return utf8ify(text5) # return as utf-8 byte string
+
def showImagesOfPage(self,imageUrl=None):
"""show Images of project"""