Commit 02198cc9 authored by Vincent Pelletier's avatar Vincent Pelletier

Be more robust against malformed related key definitions.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25714 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ffc3f1f7
......@@ -1734,7 +1734,11 @@ class Catalog(Folder,
column_map = self.getColumnMap()
column_set = set(column_map)
for related_key in self.sql_catalog_related_keys:
related_key_id = related_key.split(' | ')[0].strip()
split_entire_definition = related_key.split('|')
if len(split_entire_definition) != 2:
LOG('SQLCatalog', 100, 'Malformed related key definition: %r. Ignored.' % (entire_definition, ))
continue
related_key_id = split_entire_definition[0].strip()
if related_key_id in column_set:
LOG('SQLCatalog', 100, 'Related key %r has the same name as an existing column on tables %r' % (related_key_id, column_map[related_key_id]))
column_set.add(related_key_id)
......@@ -1796,7 +1800,11 @@ class Catalog(Folder,
except KeyError:
result = None
for entire_definition in self.getSQLCatalogRelatedKeyList([key]):
name, definition = entire_definition.split(' | ')
split_entire_definition = entire_definition.split('|')
if len(split_entire_definition) != 2:
LOG('SQLCatalog', 100, 'Malformed related key definition: %r. Ignored.' % (entire_definition, ))
continue
name, definition = [x.strip() for x in split_entire_definition]
if name == key:
result = definition
break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment