[ZCM] [ZC] 2275/ 2 Comment "Unicode error in Page Templates"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Mon, 05 Feb 2007 06:55:55 -0500
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2275 Update (Comment) "Unicode error in Page Templates"
 Status Pending, Zope/bug+solution medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2275

==============================================================
= Comment - Entry #2 by ajung on Feb 5, 2007 6:55 am

Could you please work on a unittest?
________________________________________
= Request - Entry #1 by don on Feb 5, 2007 6:39 am

I add Page Template, set Content-Type to text/plain, output-encofing to koi8-r, write text with cyrillic characters and try to save it. And get an error:
Error Type: TypeError
Error Value: decoding Unicode is not supported
Environment:
management_page_charset property set to "koi8-r"
environment variable ZPT_PREFERRED_ENCODING="koi8-r"
overrides.zcml in /Products/PageTemplates with ReplacingUnicodeEncodingConflictResolver
Error was gone after adding 2 lines in /Products/PageTemplates/utils.py in function convertToUnicode:
replace
        try:
            return unicode(source, enc), enc
        except UnicodeDecodeError:
                continue

with

        try:
            return unicode(source, enc), enc
        except UnicodeDecodeError:
                continue
        except TypeError:
                continue

==============================================================