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 ...@@ -135,6 +135,9 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Collector #2338: ZPT: fixed unicode issue when using the 'structure'
directive
- Collector #2332: SessionDataManger: don't swallow ConflictErrors - Collector #2332: SessionDataManger: don't swallow ConflictErrors
- ZopePageTemplate's pt_edit did not recognize content type arguments - ZopePageTemplate's pt_edit did not recognize content type arguments
......
...@@ -192,11 +192,23 @@ class ZopeContext(Context): ...@@ -192,11 +192,23 @@ class ZopeContext(Context):
return value return value
return bool(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): def evaluateText(self, expr):
""" customized version in order to get rid of unicode """ customized version in order to get rid of unicode
errors for all and ever errors for all and ever
""" """
text = self.evaluate(expr) 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: if text is self.getDefault() or text is None:
# XXX: should be unicode??? # XXX: should be unicode???
......
...@@ -121,6 +121,16 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase): ...@@ -121,6 +121,16 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
result = zpt.pt_render() result = zpt.pt_render()
self.assertEqual(result.startswith(unicode('<div></div>', 'iso-8859-15')), False) 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): 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