kernel: improve check on xml_id

bzr revid: ced-19cafbc2cf94c22894ecabdc5745cb42f0af4099
This commit is contained in:
ced 2007-07-03 14:28:11 +00:00
parent 8a53a694b1
commit c0d04a6b6a
1 changed files with 13 additions and 12 deletions

View File

@ -124,6 +124,13 @@ def escape(x):
return x.replace('\\/', '/')
class xml_import(object):
def _test_xml_id(self, xml_id):
id = xml_id
if '.' in xml_id:
base, id = xml_id.split('.')
if len(id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
def _tag_delete(self, cr, rec, data_node=None):
d_model = rec.getAttribute("model")
d_search = rec.getAttribute("search")
@ -150,8 +157,7 @@ class xml_import(object):
res['header'] = eval(rec.getAttribute('header'))
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
xml_id = rec.getAttribute('id').encode('utf8')
if len(xml_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
self._test_xml_id(xml_id)
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode)
self.idref[xml_id] = id
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
@ -171,8 +177,7 @@ class xml_import(object):
model = rec.getAttribute("model").encode('utf8')
name = rec.getAttribute("name").encode('utf8')
xml_id = rec.getAttribute('id').encode('utf8')
if len(xml_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
self._test_xml_id(xml_id)
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
res = {'name': string, 'wiz_name': name, 'multi':multi}
@ -190,8 +195,7 @@ class xml_import(object):
def _tag_act_window(self, cr, rec, data_node=None):
name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8')
xml_id = rec.getAttribute('id').encode('utf8')
if len(xml_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
self._test_xml_id(xml_id)
type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window'
view_id = False
if rec.hasAttribute('view'):
@ -238,8 +242,7 @@ class xml_import(object):
def _tag_menuitem(self, cr, rec, data_node=None):
rec_id = rec.getAttribute("id").encode('ascii')
if len(rec_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id)
self._test_xml_id(rec_id)
m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8')))
pid = False
for idx, menu_elem in enumerate(m_l):
@ -290,8 +293,7 @@ class xml_import(object):
g_ids.extend(self.pool.get('res.groups').search(cr, self.uid, [('name', '=', group)]))
values['groups_id'] = [(6, 0, g_ids)]
xml_id = rec.getAttribute('id').encode('utf8')
if len(xml_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
self._test_xml_id(xml_id)
pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, idx==len(m_l)-1, mode=self.mode, res_id=res and res[0] or False)
elif res:
# the menuitem already exists
@ -320,8 +322,7 @@ class xml_import(object):
model = self.pool.get(rec_model)
assert model, "The model %s does not exist !" % (rec_model,)
rec_id = rec.getAttribute("id").encode('ascii')
if len(rec_id) > 64:
self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id)
self._test_xml_id(rec_id)
# if not rec_id and not data_node.getAttribute('noupdate'):
# print "Warning", rec_model