Commit c9f3c5ec authored by Andreas Jung's avatar Andreas Jung

- Collector #2339: ZPT: fixed unicode issue when using the 'structure' directive

- ZopeContext: added evaluateStructure() and refactored _handleText() in order
to deal with unicode issues when using the 'structure' directive
parent 75d48b46
......@@ -135,6 +135,9 @@ Zope Changes
Bugs Fixed
- Collector #2338: ZPT: fixed unicode issue when using the 'structure'
directive
- Collector #2332: SessionDataManger: don't swallow ConflictErrors
- ZopePageTemplate's pt_edit did not recognize content type arguments
......
......@@ -192,11 +192,23 @@ class ZopeContext(Context):
return value
return bool(value)
def evaluateStructure(self, expr):
""" customized version in order to get rid of unicode
errors for all and ever
"""
text = super(ZopeContext, self).evaluateStructure(expr)
return self._handleText(text, expr)
def evaluateText(self, expr):
""" customized version in order to get rid of unicode
errors for all and ever
"""
text = self.evaluate(expr)
return self._handleText(text, expr)
def _handleText(self, text, expr):
text = self.evaluate(expr)
if text is self.getDefault() or text is None:
# XXX: should be unicode???
......
......@@ -121,6 +121,16 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
result = zpt.pt_render()
self.assertEqual(result.startswith(unicode('<div></div>', 'iso-8859-15')), False)
def testStructureWithAccentedChars(self):
manage_addPageTemplate(self.app, 'test',
text='<div tal:content="structure python: %s" />' % "''",
encoding='iso-8859-15')
zpt = self.app['test']
self.app.REQUEST.set('HTTP_ACCEPT_CHARSET', 'iso-8859-15,utf-8')
self.app.REQUEST.set('data', unicode('', 'iso-8859-15').encode('utf-8'))
result = zpt.pt_render()
self.assertEqual(result.startswith(unicode('<div></div>', 'iso-8859-15')), True)
class ZopePageTemplateFileTests(ZopeTestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment