[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/t Make sure that no_doctype overrides parsed doctype.

Chris McDonough chrism at plope.com
Mon Sep 1 17:19:56 EDT 2008


Log message for revision 90670:
  Make sure that no_doctype overrides parsed doctype.
  

Changed:
  U   z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py
  U   z3c.pt/trunk/src/z3c/pt/translation.py

-=-
Modified: z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py	2008-09-01 20:23:47 UTC (rev 90669)
+++ z3c.pt/trunk/src/z3c/pt/tests/test_edgecases.py	2008-09-01 21:19:55 UTC (rev 90670)
@@ -178,6 +178,24 @@
         t.doctype = doctypes.html
         self.assertEqual(norm(t.render()), norm(expected))
 
+    def test_no_doctype_overrides_parsed_doctype(self):
+        import z3c.pt
+        from zope.configuration import xmlconfig
+        xmlconfig.file('configure.zcml', z3c.pt)
+        from z3c.pt.pagetemplate import PageTemplate
+        from z3c.pt import doctypes
+        body = """\
+        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+        <html xmlns="http://www.w3.org/1999/xhtml">
+        </html>
+        """
+        expected = """\
+        <html>
+        </html>"""
+        t = PageTemplate(body, doctype=doctypes.no_doctype)
+        self.assertEqual(norm(t.render()), norm(expected))
+
 class TestBadAttributeInterpolationWithTAL(unittest.TestCase, PlacelessSetup):
     def test_snippet(self):
         body = """\

Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py	2008-09-01 20:23:47 UTC (rev 90669)
+++ z3c.pt/trunk/src/z3c/pt/translation.py	2008-09-01 21:19:55 UTC (rev 90670)
@@ -3,6 +3,7 @@
 import generation
 import codegen
 import clauses
+import doctypes
 import itertools
 import types
 import utils
@@ -438,7 +439,10 @@
     
     def __init__(self, body, parser, doctype=None):
         self.root, parsed_doctype = parser.parse(body)
-        self.doctype = doctype or parsed_doctype
+        if doctype is doctypes.no_doctype:
+            self.doctype = None
+        else:
+            self.doctype = doctype or parsed_doctype
         self.parser = parser
 
     @classmethod



More information about the Checkins mailing list