[Zope-Checkins] SVN: Zope/branches/2.11/ Launchpad #198274: "empty"
ZopePageTemplates could not be unpickled.
Tres Seaver
tseaver at palladion.com
Tue Mar 4 13:10:19 EST 2008
Log message for revision 84463:
Launchpad #198274: "empty" ZopePageTemplates could not be unpickled.
Changed:
U Zope/branches/2.11/doc/CHANGES.txt
U Zope/branches/2.11/lib/python/Products/PageTemplates/ZopePageTemplate.py
U Zope/branches/2.11/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.11/doc/CHANGES.txt 2008-03-04 18:05:50 UTC (rev 84462)
+++ Zope/branches/2.11/doc/CHANGES.txt 2008-03-04 18:10:17 UTC (rev 84463)
@@ -8,6 +8,9 @@
Bugs Fixed
+ - Launchpad #198274: "empty" ZopePageTemplates could not be
+ unpickled.
+
Zope 2.11 beta 1 (2007/12/29)
Restructuring
Modified: Zope/branches/2.11/lib/python/Products/PageTemplates/ZopePageTemplate.py
===================================================================
--- Zope/branches/2.11/lib/python/Products/PageTemplates/ZopePageTemplate.py 2008-03-04 18:05:50 UTC (rev 84462)
+++ Zope/branches/2.11/lib/python/Products/PageTemplates/ZopePageTemplate.py 2008-03-04 18:10:17 UTC (rev 84463)
@@ -413,7 +413,8 @@
# Perform on-the-fly migration to unicode.
# Perhaps it might be better to work with the 'generation' module
# 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'],
state.get('content_type', 'text/html'),
preferred_encodings)
Modified: Zope/branches/2.11/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
===================================================================
--- Zope/branches/2.11/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2008-03-04 18:05:50 UTC (rev 84462)
+++ Zope/branches/2.11/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2008-03-04 18:10:17 UTC (rev 84463)
@@ -141,6 +141,17 @@
result = zpt.pt_render()
self.assertEqual(result.startswith(unicode('<div>üöä</div>', 'iso-8859-15')), True)
+ 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):
def testPT_RenderWithAscii(self):
More information about the Zope-Checkins
mailing list