Log message for revision 71928: merge from HEAD Changed: U Zope/branches/2.10/lib/python/Products/PageTemplates/ZopePageTemplate.py U Zope/branches/2.10/lib/python/Products/PageTemplates/utils.py
-=- Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/ZopePageTemplate.py =================================================================== --- Zope/branches/2.10/lib/python/Products/PageTemplates/ZopePageTemplate.py 2007-01-11 17:13:14 UTC (rev 71927) +++ Zope/branches/2.10/lib/python/Products/PageTemplates/ZopePageTemplate.py 2007-01-11 18:25:48 UTC (rev 71928) @@ -126,7 +126,7 @@ encoding = None output_encoding = None - if content_type == 'text/xml': + if content_type in ('text/xml',): if is_unicode: encoding = None @@ -136,7 +136,7 @@ output_encoding = 'utf-8' - elif content_type == 'text/html': + elif content_type in ('text/html',) : charset = charsetFromMetaEquiv(text) @@ -156,7 +156,10 @@ output_encoding = 'iso-8859-15' else: - raise ValueError('Unsupported content-type %s' % content_type) + utext, encoding = convertToUnicode(text, + content_type, + preferred_encodings) + output_encoding = encoding # for content updated through WebDAV, FTP if not keep_output_encoding: @@ -228,8 +231,8 @@ text = file.read() content_type = guess_type(filename, text) - if not content_type in ('text/html', 'text/xml'): - raise ValueError('Unsupported mimetype: %s' % content_type) +# if not content_type in ('text/html', 'text/xml'): +# raise ValueError('Unsupported mimetype: %s' % content_type) self.pt_edit(text, content_type) return self.pt_editForm(manage_tabs_message='Saved changes') @@ -409,7 +412,8 @@ def __setstate__(self, state): # Perform on-the-fly migration to unicode. - # Perhaps it might be work with the 'generation' module here? + # Perhaps it might be better to work with the 'generation' module + # here? if not isinstance(state['_text'], unicode): text, encoding = convertToUnicode(state['_text'], state.get('content_type', 'text/html'), Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/utils.py =================================================================== --- Zope/branches/2.10/lib/python/Products/PageTemplates/utils.py 2007-01-11 17:13:14 UTC (rev 71927) +++ Zope/branches/2.10/lib/python/Products/PageTemplates/utils.py 2007-01-11 18:25:48 UTC (rev 71928) @@ -70,20 +70,19 @@ elif content_type.startswith('text/html'): encoding = charsetFromMetaEquiv(source) + if encoding: + return unicode(source, encoding), encoding - # Try to detect the encoding by converting it unicode without raising - # exceptions. There are some smarter Python-based sniffer methods - # available however we have to check their licenses first before - # including them into the Zope 2 core + # Try to detect the encoding by converting it unicode without raising + # exceptions. There are some smarter Python-based sniffer methods + # available however we have to check their licenses first before + # including them into the Zope 2 core - if not encoding: - for enc in preferred_encodings: - try: - return unicode(source, enc), enc - except UnicodeDecodeError: - continue + for enc in preferred_encodings: + try: + return unicode(source, enc), enc + except UnicodeDecodeError: + continue - raise TypeError('Could not auto-detect encoding') + return unicode(source), None - else: - raise ValueError('Unsupported content-type: %s' % content_type) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins