Merge lp:~unifield-team/unifield-server/uf3.1 into lp:unifield-server/uf3

Proposed by jftempo
Status: Merged
Merged at revision: 4132
Proposed branch: lp:~unifield-team/unifield-server/uf3.1
Merge into: lp:unifield-server/uf3
Diff against target: 110 lines (+33/-19)
1 file modified
bin/tools/convert.py (+33/-19)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/uf3.1
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+315451@code.launchpad.net

Description of the change

Issue with relative path in xml file on Windows system.

Liked to US-1135 and this kind of directive in account/wizard/account_report_common_view.xml:
 <!ENTITY wizard_template SYSTEM "../../resource/wizard_template_view.xml">
On Win, path is relative to config['addons_path']/account
it should be config['addons_path']/account/wizard

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/tools/convert.py'
2--- bin/tools/convert.py 2013-11-07 16:50:06 +0000
3+++ bin/tools/convert.py 2017-01-24 11:17:59 +0000
4@@ -47,7 +47,6 @@
5 import pooler
6 from config import config
7 from tools.translate import _
8-from yaml_import import convert_yaml_import
9
10 # List of etree._Element subclasses that we choose to ignore when parsing XML.
11 from tools import SKIPPED_ELEMENT_TYPES, cache
12@@ -551,8 +550,8 @@
13 uid = self.get_uid(cr, self.uid, data_node, rec)
14 wf_service = netsvc.LocalService("workflow")
15 wf_service.trg_validate(uid, model,
16- id,
17- str(rec.get('action','')), cr)
18+ id,
19+ str(rec.get('action','')), cr)
20
21 #
22 # Support two types of notation:
23@@ -794,7 +793,7 @@
24 return None
25 res = {}
26 for field in rec.findall('./field'):
27-#TODO: most of this code is duplicated above (in _eval_xml)...
28+ #TODO: most of this code is duplicated above (in _eval_xml)...
29 f_name = field.get("name",'').encode('utf-8')
30 f_ref = field.get("ref",'').encode('utf-8')
31 f_search = field.get("search",'').encode('utf-8')
32@@ -825,7 +824,7 @@
33 f_val = False
34 else:
35 if f_name in model._columns \
36- and model._columns[f_name]._type == 'reference':
37+ and model._columns[f_name]._type == 'reference':
38 val = self.model_id_get(cr, f_ref)
39 f_val = val[0] + ',' + str(val[1])
40 else:
41@@ -868,17 +867,17 @@
42
43 for n in de.findall('./data'):
44 for rec in n:
45- if rec.tag in self._tags:
46- try:
47- self._tags[rec.tag](self.cr, rec, n)
48- except:
49- self.__logger.error('Parse error in %s:%d: \n%s',
50- rec.getroottree().docinfo.URL,
51- rec.sourceline,
52- etree.tostring(rec).strip(), exc_info=True)
53- self.cr.rollback()
54- cache.clean_caches_for_db(self.cr.dbname)
55- raise
56+ if rec.tag in self._tags:
57+ try:
58+ self._tags[rec.tag](self.cr, rec, n)
59+ except:
60+ self.__logger.error('Parse error in %s:%d: \n%s',
61+ rec.getroottree().docinfo.URL,
62+ rec.sourceline,
63+ etree.tostring(rec).strip(), exc_info=True)
64+ self.cr.rollback()
65+ cache.clean_caches_for_db(self.cr.dbname)
66+ raise
67 return True
68
69 def __init__(self, cr, module, idref, mode, report=None, noupdate=False):
70@@ -909,7 +908,7 @@
71 }
72
73 def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
74- noupdate=False):
75+ noupdate=False):
76 '''Import csv file :
77 quote: "
78 delimiter: ,
79@@ -978,14 +977,29 @@
80 if os.path.exists(filepath):
81 fp = open(filepath, 'rb')
82 return self.resolve_file(fp, context)
83- except IOError, e:
84+ except IOError:
85 pass
86 #
87 # xml import/export
88 #
89 def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=False, report=None):
90 parser = etree.XMLParser()
91- parser.resolvers.add(ModuleEntityResolver([config['addons_path']], module))
92+
93+
94+ # if xmlfile is in a subdir (i.e: module/wizard/view.xml)
95+ # path set in ENTITY ... SYSTEM should relate to addons_path/module/wizard
96+ # on Win wizard dir was missing
97+ module_path = os.path.join(config['addons_path'], module)
98+ sub_dir = module
99+ if isinstance(xmlfile, file):
100+ xmlfile_name = xmlfile.name
101+ common_prefix = os.path.commonprefix([module_path, xmlfile_name])
102+ xmlfile_dir = os.path.dirname(xmlfile_name)
103+ extra_dir = os.path.relpath(xmlfile_dir, common_prefix)
104+ if extra_dir:
105+ sub_dir = os.path.join(extra_dir, module)
106+
107+ parser.resolvers.add(ModuleEntityResolver([config['addons_path']], sub_dir))
108 doc = etree.parse(xmlfile, parser)
109 relaxng = etree.RelaxNG(
110 etree.parse(os.path.join(config['root_path'],'import_xml.rng' )))

Subscribers

People subscribed via source and target branches

to all changes: