--- ECHO_content/ECHO_helpers.py 2007/05/03 14:23:46 1.82 +++ ECHO_content/ECHO_helpers.py 2007/07/24 09:11:46 1.84 @@ -35,6 +35,29 @@ def encodeRPC(string): def decodeRPC(string): return bz2.decompress(base64.decodestring(string)) +def unicodify(s): + """decode str (utf-8 or latin-1 representation) into unicode object""" + if not s: + return u"" + if isinstance(s, str): + try: + return s.decode('utf-8') + except: + return s.decode('latin-1') + else: + return s + +def utf8ify(s): + """encode unicode object or string into byte string in utf-8 representation. + assumes string objects to be utf-8""" + if not s: + return "" + if isinstance(s, str): + return s + else: + return s.encode('utf-8') + + def content_html(self,type): """template fuer content""" #templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) @@ -1220,6 +1243,8 @@ class MapText(Folder,ZopePageTemplate): self.ZBindings_edit(self._default_bindings) if text is None: text = open(self._default_content_fn).read() + if content_type is None: + content_type = self.content_type self.pt_edit(text, content_type) def createLocale(self):