Use proper try/exception format
This commit is contained in:
@@ -81,6 +81,13 @@ def cascade_eval(eval_dict, document, template_node, parent_index_instance=None)
|
|||||||
if template_node.enabled:
|
if template_node.enabled:
|
||||||
try:
|
try:
|
||||||
result = eval(template_node.expression, eval_dict, AVAILABLE_INDEXING_FUNCTIONS)
|
result = eval(template_node.expression, eval_dict, AVAILABLE_INDEXING_FUNCTIONS)
|
||||||
|
except (NameError, AttributeError), exc:
|
||||||
|
warnings.append(_(u'Error in document indexing update expression: %(expression)s; %(exception)s') % {
|
||||||
|
'expression': template_node.expression, 'exception': exc})
|
||||||
|
except Exception, exc:
|
||||||
|
warnings.append(_(u'Error updating document index, expression: %(expression)s; %(exception)s') % {
|
||||||
|
'expression': template_node.expression, 'exception': exc})
|
||||||
|
else:
|
||||||
if result:
|
if result:
|
||||||
index_instance, created = IndexInstanceNode.objects.get_or_create(index_template_node=template_node)
|
index_instance, created = IndexInstanceNode.objects.get_or_create(index_template_node=template_node)
|
||||||
index_instance.value = result
|
index_instance.value = result
|
||||||
@@ -106,13 +113,6 @@ def cascade_eval(eval_dict, document, template_node, parent_index_instance=None)
|
|||||||
)
|
)
|
||||||
warnings.extend(children_warnings)
|
warnings.extend(children_warnings)
|
||||||
|
|
||||||
except (NameError, AttributeError), exc:
|
|
||||||
warnings.append(_(u'Error in document indexing update expression: %(expression)s; %(exception)s') % {
|
|
||||||
'expression': template_node.expression, 'exception': exc})
|
|
||||||
except Exception, exc:
|
|
||||||
warnings.append(_(u'Error updating document index, expression: %(expression)s; %(exception)s') % {
|
|
||||||
'expression': template_node.expression, 'exception': exc})
|
|
||||||
|
|
||||||
return warnings
|
return warnings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user