Commit 284f3fd7 authored by Tres Seaver's avatar Tres Seaver

Launchpad #198274: "empty" ZopePageTemplates could not be unpickled.

parent 00e50564
...@@ -8,6 +8,9 @@ Zope Changes ...@@ -8,6 +8,9 @@ Zope Changes
Bugs fixed Bugs fixed
- Launchpad #198274: "empty" ZopePageTemplates could not be
unpickled.
- zope.security: switched to use standalone 3.3.3 version, which - zope.security: switched to use standalone 3.3.3 version, which
contains a backport of a huge performance bugfix from the 3.4 branch. contains a backport of a huge performance bugfix from the 3.4 branch.
......
...@@ -413,7 +413,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -413,7 +413,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
# Perform on-the-fly migration to unicode. # Perform on-the-fly migration to unicode.
# Perhaps it might be better to work with the 'generation' module # Perhaps it might be better to work with the 'generation' module
# here? # here?
if not isinstance(state['_text'], unicode): _text = state.get('_text')
if _text is not None and not isinstance(state['_text'], unicode):
text, encoding = convertToUnicode(state['_text'], text, encoding = convertToUnicode(state['_text'],
state.get('content_type', 'text/html'), state.get('content_type', 'text/html'),
preferred_encodings) preferred_encodings)
......
...@@ -141,6 +141,17 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase): ...@@ -141,6 +141,17 @@ 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 test_bug_198274(self):
# See https://bugs.launchpad.net/bugs/198274
# ZPT w/ '_text' not assigned can't be unpickled.
import cPickle
empty = ZopePageTemplate(id='empty', text=' ',
content_type='text/html',
output_encoding='ascii',
)
state = cPickle.dumps(empty, protocol=1)
clone = cPickle.loads(state)
class ZopePageTemplateFileTests(ZopeTestCase): class ZopePageTemplateFileTests(ZopeTestCase):
def testPT_RenderWithAscii(self): def testPT_RenderWithAscii(self):
......
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