From a56dc53beaabf7ba97908f5d335f72fda9b2aa0b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Mar 2014 08:54:19 +0100 Subject: [PATCH] [REM] 4-spaces indent for web view pretty-print-before-save routine Didn't quite work right: on the layout, it would exponentially increase leading spaces in text nodes. Combined with a bug injecting snippets marks in the footer (and thus invalidating and re-saving the layout at each snippet addition) this could blow up the layout template and rendered page to >20MB. Just keep lxml's standard 2-spaces indent. LXML is unable to pretty print the layout anyway. bzr revid: xmo@openerp.com-20140321075419-9w88h232r928xv5f --- addons/website/models/ir_ui_view.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 857b99d40d2..67781cc02a0 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -168,20 +168,9 @@ class view(osv.osv): arch_no_whitespace = etree.fromstring( etree.tostring(arch, encoding='utf-8'), parser=etree.XMLParser(encoding='utf-8', remove_blank_text=True)) - arch_pretty_indent_2 = etree.tostring( + return etree.tostring( arch_no_whitespace, encoding='unicode', pretty_print=True) - # pretty_print uses a fixed indent level of 2, we want an indent of 4, - # double up leading spaces. - def repl(m): - indent = len(m.group(0)) / 2 - return u' ' * 4 * indent - # FIXME: If py2.7 only, can use re.M in sub and don't have to do replacement line by line - return u'\n'.join( - re.sub(ur'^((?: )+)', repl, line) - for line in arch_pretty_indent_2.split(u'\n') - ) - def save(self, cr, uid, res_id, value, xpath=None, context=None): """ Update a view section. The view section may embed fields to write