[FIX] exception rendering with pretty printed XML
authorXavier Morel <xmo@openerp.com>
Mon, 14 Jul 2014 11:42:29 +0000 (13:42 +0200)
committerXavier Morel <xmo@openerp.com>
Mon, 14 Jul 2014 11:44:37 +0000 (13:44 +0200)
had not been migrated to lxml

addons/website/views/website_templates.xml
openerp/addons/base/ir/ir_qweb.py

index dab4363..36104f4 100644 (file)
                         <t t-if="'expression' in qweb_exception.qweb">and evaluating the following expression: <code t-esc="qweb_exception.qweb['expression']"/></t>
                     </p>
                     <t t-if="'node' in qweb_exception.qweb">
-                        <pre id="exception_node" t-esc="qweb_exception.qweb['node'].toxml()"/>
+                        <pre id="exception_node" t-esc="qweb_exception.pretty_xml()"/>
                     </t>
                 </div>
             </div>
index 30763a6..918f54f 100644 (file)
@@ -40,6 +40,10 @@ class QWebException(Exception):
     def __init__(self, message, **kw):
         Exception.__init__(self, message)
         self.qweb = dict(kw)
+    def pretty_xml(self):
+        if 'node' not in self.qweb:
+            return ''
+        return etree.tostring(self.qweb['node'], pretty_print=True)
 
 class QWebTemplateNotFound(QWebException):
     pass