Commit fa5c531f authored by Tres Seaver's avatar Tres Seaver

Forward port fix for Launchpad #229549 from the 2.10 branch.

parent 04687d0e
......@@ -68,7 +68,15 @@ class PageTemplate(ExtensionClass.Base,
def pt_render(self, source=False, extra_context={}):
c = self.pt_getContext()
c.update(extra_context)
return super(PageTemplate, self).pt_render(c, source=source)
debug = getattr(c['request'], 'debug', None)
if debug is not None:
showtal = getattr(debug, 'showTAL', False)
sourceAnnotations = getattr(debug, 'sourceAnnotations', False)
else:
showtal = sourceAnnotations = False
return super(PageTemplate, self).pt_render(c, source=source, sourceAnnotations=sourceAnnotations,
showtal=showtal)
def pt_errors(self, namespace={}):
self._cook_check()
......
......@@ -202,6 +202,20 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
state = cPickle.dumps(empty, protocol=1)
clone = cPickle.loads(state)
def testDebugFlags(self):
# Test for bug 229549
manage_addPageTemplate(self.app, 'test',
text='<div tal:content="string:foo">bar</div>',
encoding='ascii')
zpt = self.app['test']
from zope.publisher.base import DebugFlags
self.app.REQUEST.debug = DebugFlags()
self.assertEqual(zpt.pt_render(), unicode('<div>foo</div>\n'))
self.app.REQUEST.debug.showTAL = True
self.assertEqual(zpt.pt_render(), unicode('<div tal:content="string:foo">foo</div>\n'))
self.app.REQUEST.debug.sourceAnnotations = True
self.assertEqual(zpt.pt_render().startswith(unicode('<!--')), True)
class ZopePageTemplateFileTests(ZopeTestCase):
def test_class_conforms_to_IWriteLock(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