Commit 073d3196 authored by Romain Courteaud's avatar Romain Courteaud

Changed code layout.

Bug fix: catch IndexError instead of KeyError.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5027 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0171bb8d
...@@ -880,7 +880,9 @@ class ListBoxWidget(Widget.Widget): ...@@ -880,7 +880,9 @@ class ListBoxWidget(Widget.Widget):
############################################################### ###############################################################
select_expression = '' select_expression = ''
if show_stat: if show_stat:
stats = here.portal_selections.getSelectionStats(selection_name, REQUEST=REQUEST) stats = here.portal_selections.getSelectionStats(
selection_name,
REQUEST=REQUEST)
index = 0 index = 0
for (sql,title,alias) in extended_columns: for (sql,title,alias) in extended_columns:
...@@ -890,14 +892,15 @@ class ListBoxWidget(Widget.Widget): ...@@ -890,14 +892,15 @@ class ListBoxWidget(Widget.Widget):
break break
else: else:
column = None column = None
if column is not None and column[0] == column[1]: if (column is not None) and (column[0] == column[1]):
try: try:
if stats[index] != ' ': if stats[index] != ' ':
select_expression += stats[index] + '(' + sql + ') AS ' + alias + ',' select_expression += '%s(%s) AS %s,' % (stats[index], sql,
alias)
else: else:
select_expression += '\' \' AS ' + alias + ',' select_expression += '\' \' AS %s,' % alias
except KeyError: except IndexError:
select_expression += '\' \' AS ' + alias + ',' select_expression += '\' \' AS %s,' % alias
index = index + 1 index = index + 1
select_expression = select_expression[:len(select_expression) - 1] select_expression = select_expression[:len(select_expression) - 1]
...@@ -1211,15 +1214,22 @@ class ListBoxWidget(Widget.Widget): ...@@ -1211,15 +1214,22 @@ class ListBoxWidget(Widget.Widget):
format_dict = { format_dict = {
'portal_url_string' : portal_url_string, 'portal_url_string' : portal_url_string,
'list_action' : list_action, 'list_action' : list_action,
'selection_name' : selection_name,
'field_title' : translate('ui', field_title, default = field_title), 'field_title' : translate('ui', field_title, default = field_title),
'pages' : pages, 'pages' : pages,
'record_number' : translate('ui', '${number} record(s)', default = '%s record(s)' % total_size, 'record_number' : translate('ui', '${number} record(s)',
default = '%s record(s)' % total_size,
mapping = { 'number' : str(total_size) }), mapping = { 'number' : str(total_size) }),
'item_number' : translate('ui', '${number} item(s) selected', default = '%s item(s) selected' % len(checked_uids), 'item_number' : translate('ui', '${number} item(s) selected',
mapping = { 'number' : str(len(checked_uids)) }), default = '%s item(s) selected' % \
'flat_list_title': translate('ui', 'Flat List', default = 'Flat List'), len(checked_uids),
'report_tree_title': translate('ui', 'Report Tree', default = 'Report Tree'), mapping = { 'number' : \
'domain_tree_title': translate('ui', 'Domain Tree', default = 'Domain Tree'), str(len(checked_uids)) }),
'flat_list_title': translate('ui', 'Flat List', default='Flat List'),
'report_tree_title': translate('ui', 'Report Tree',
default = 'Report Tree'),
'domain_tree_title': translate('ui', 'Domain Tree',
default = 'Domain Tree'),
} }
header = """\ header = """\
<!-- List Summary --> <!-- List Summary -->
...@@ -1845,7 +1855,6 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')"> ...@@ -1845,7 +1855,6 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
kw['select_expression'] = select_expression kw['select_expression'] = select_expression
selection.edit( params = kw ) selection.edit( params = kw )
count_results = selection(method = stat_method, count_results = selection(method = stat_method,
context=here, REQUEST=REQUEST) context=here, REQUEST=REQUEST)
list_body = list_body + '<tr>' list_body = list_body + '<tr>'
......
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