[FIX] handle the case when xml are in unicode
bzr revid: christophe@cobalt-20081216105858-q0q02gxjt95qbmus
This commit is contained in:
parent
746373320e
commit
88c097516a
|
@ -28,7 +28,7 @@ import os
|
|||
|
||||
def _check_xml(self, cr, uid, ids, context={}):
|
||||
for view in self.browse(cr, uid, ids, context):
|
||||
eview = etree.fromstring(view.arch)
|
||||
eview = etree.fromstring(view.arch.encode('utf8'))
|
||||
frng = tools.file_open(os.path.join('base','rng','view.rng'))
|
||||
relaxng = etree.RelaxNG(file=frng)
|
||||
if not relaxng.validate(eview):
|
||||
|
|
|
@ -918,6 +918,12 @@ class orm_template(object):
|
|||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
def encode(s):
|
||||
if isinstance(s, unicode):
|
||||
return s.encode('utf8')
|
||||
return s
|
||||
|
||||
def _inherit_apply(src, inherit):
|
||||
def _find(node, node2):
|
||||
if node2.nodeType == node2.ELEMENT_NODE and node2.localName == 'xpath':
|
||||
|
@ -940,9 +946,11 @@ class orm_template(object):
|
|||
if res:
|
||||
return res
|
||||
return None
|
||||
|
||||
|
||||
doc_src = dom.minidom.parseString(src)
|
||||
doc_dest = dom.minidom.parseString(inherit)
|
||||
netsvc.Logger().notifyChannel('orm', netsvc.LOG_DEBUG, type(src))
|
||||
doc_src = dom.minidom.parseString(encode(src))
|
||||
doc_dest = dom.minidom.parseString(encode(inherit))
|
||||
toparse = doc_dest.childNodes
|
||||
while len(toparse):
|
||||
node2 = toparse.pop(0)
|
||||
|
@ -1057,7 +1065,7 @@ class orm_template(object):
|
|||
result['field_parent'] = False
|
||||
result['view_id'] = 0
|
||||
|
||||
doc = dom.minidom.parseString(result['arch'].encode('utf-8'))
|
||||
doc = dom.minidom.parseString(encode(result['arch']))
|
||||
xarch, xfields = self.__view_look_dom_arch(cr, user, doc, context=context)
|
||||
result['arch'] = xarch
|
||||
result['fields'] = xfields
|
||||
|
|
Loading…
Reference in New Issue