From 20e8c4334a59f5829398d0288ebef7f3c22bacae Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Fri, 9 Oct 2009 11:08:55 +0530 Subject: [PATCH] [REF]:Added Exception message in report engine when there is problem while eval(code) bzr revid: nch@tinyerp.com-20091009053855-n320ioc366stvt08 --- bin/report/render/rml2pdf/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/report/render/rml2pdf/utils.py b/bin/report/render/rml2pdf/utils.py index 59724d7d1b4..11c027d202a 100644 --- a/bin/report/render/rml2pdf/utils.py +++ b/bin/report/render/rml2pdf/utils.py @@ -42,6 +42,8 @@ import reportlab from lxml import etree import copy import tools +import netsvc +import traceback, sys _regex = re.compile('\[\[(.+?)\]\]') @@ -107,9 +109,11 @@ def _process_text(self, txt): result += self.localcontext.get('translate', lambda x:x)(sps.pop(0)) if sps: try: - txt = eval(sps.pop(0),self.localcontext) - except: - pass + expr = sps.pop(0) + txt = eval(expr,self.localcontext) + except Exception,e: + tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) + netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e),expr.encode('utf-8'))) if type(txt)==type('') or type(txt)==type(u''): txt2 = str2xml(txt) result += tools.ustr(txt2) @@ -163,7 +167,7 @@ def attr_get(node, attrs, dict={}): res[key] = int(node.get(key)) elif dict[key]=='unit': res[key] = unit_get(node.get(key)) - elif dict[key] == 'float' : + elif dict[key] == 'float' : res[key] = float(node.get(key)) return res