Log message for revision 87216:
  Launchpad #229549:  Don't ignore 'debug' flag when rendering page templates
  
  Thanks to Eric Steele for the patch.
  

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/Products/PageTemplates/PageTemplate.py
  U   
Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt  2008-06-06 18:39:19 UTC (rev 87215)
+++ Zope/branches/2.10/doc/CHANGES.txt  2008-06-06 20:13:25 UTC (rev 87216)
@@ -8,6 +8,9 @@
 
     Bugs fixed
 
+      - Launchpad #229549:  Don't ignore 'debug' flag when rendering
+        page templates (thanks to Eric Steele for the patch).
+
   Zope 2.10.6 (2008/05/10)
 
     Bugs fixed

Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/PageTemplate.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/PageTemplate.py        
2008-06-06 18:39:19 UTC (rev 87215)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/PageTemplate.py        
2008-06-06 20:13:25 UTC (rev 87216)
@@ -86,8 +86,16 @@
     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()
         err = self._v_errors

Modified: 
Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
===================================================================
--- 
Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
  2008-06-06 18:39:19 UTC (rev 87215)
+++ 
Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
  2008-06-06 20:13:25 UTC (rev 87216)
@@ -152,6 +152,20 @@
         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 testPT_RenderWithAscii(self):

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to