Commit 89ce4acc authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

query: Improve error checking

- Show only field definition, not callback when a result row is
- Show list of duplicate titles if there are any (module load time)
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarAdeodato Simo <>
parent 70d8ccaf
......@@ -154,7 +154,7 @@ class Query:
for (idx, row) in enumerate(result):
assert _VerifyResultRow(self._fields, row), \
("Inconsistent result for fields %s in row %s: %r" %
(self._fields, idx, row))
(GetAllFields(self._fields), idx, row))
return result
......@@ -205,9 +205,10 @@ def _PrepareFieldList(fields):
@return: Field dictionary for L{Query}
assert len(set(fdef.title.lower()
for (fdef, _, _) in fields)) == len(fields), \
"Duplicate title found"
if __debug__:
duplicates = utils.FindDuplicates(fdef.title.lower()
for (fdef, _, _) in fields)
assert not duplicates, "Duplicate title(s) found: %r" % duplicates
result = {}
......@@ -218,7 +219,8 @@ def _PrepareFieldList(fields):
assert FIELD_NAME_RE.match(
assert TITLE_RE.match(fdef.title)
assert callable(fn)
assert not in result, "Duplicate field name found"
assert not in result, \
"Duplicate field name '%s' found" %
result[] = field
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