Ensure to report the right ID for XML parsing error
The XML ID must be the first attribute to update and it should be cleared if we fail to get it. issue10768 review360141002
This commit is contained in:
1 parent
72e3bb74c7
commit
0f88889a8b
1 file changed
+14
-9
+14
-9
@@ -48,7 +48,11 @@ class MenuitemTagHandler:
|
||||
|
||||
values = {}
|
||||
|
||||
self.xml_id = attributes['id']
|
||||
try:
|
||||
self.xml_id = attributes['id']
|
||||
except KeyError:
|
||||
self.xml_id = None
|
||||
raise
|
||||
|
||||
for attr in ('name', 'sequence', 'parent', 'action', 'groups'):
|
||||
if attr in attributes:
|
||||
@@ -182,11 +186,14 @@ class RecordTagHandler:
|
||||
|
||||
# Manage the top level tag
|
||||
if name == "record":
|
||||
try:
|
||||
self.xml_id = attributes["id"]
|
||||
except KeyError:
|
||||
self.xml_id = None
|
||||
raise
|
||||
|
||||
self.model = self.mh.pool.get(attributes["model"])
|
||||
assert self.model, ("The model %s does not exist !"
|
||||
% (attributes["model"],))
|
||||
|
||||
self.xml_id = attributes["id"]
|
||||
self.update = bool(int(attributes.get('update', '0')))
|
||||
|
||||
# create/update a dict containing fields values
|
||||
@@ -300,9 +307,7 @@ class RecordTagHandler:
|
||||
raise Exception("Unexpected closing tag '%s'" % (name,))
|
||||
|
||||
def current_state(self):
|
||||
return "In tag record model %s with id %s.%s." % \
|
||||
(self.model and self.model.__name__ or "?",
|
||||
self.mh.module, self.xml_id)
|
||||
return "Tag record with id %s.%s." % (self.mh.module, self.xml_id)
|
||||
|
||||
|
||||
# Custom exception:
|
||||
@@ -454,7 +459,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
try:
|
||||
self.sax_parser.parse(source)
|
||||
except Exception as e:
|
||||
raise Exception("Error " + self.current_state()) from e
|
||||
raise Exception("Error in " + self.current_state()) from e
|
||||
return self.to_delete
|
||||
|
||||
def startElement(self, name, attributes):
|
||||
@@ -515,7 +520,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
if self.taghandler:
|
||||
return self.taghandler.current_state()
|
||||
else:
|
||||
return ''
|
||||
return '?'
|
||||
|
||||
def get_id(self, xml_id):
|
||||
|
||||
|
||||
Reference in new issue
Block a user