[REF]:notified channel when there is an exception in eval()

bzr revid: nch@tinyerp.com-20091009104547-t88ktqax7p5q57bz
This commit is contained in:
nch@tinyerp.com 2009-10-09 16:15:47 +05:30
parent dcf275be04
commit efc0d3b001
1 changed files with 10 additions and 4 deletions

View File

@ -43,6 +43,8 @@ from lxml import etree
import copy
import tools
import locale
import netsvc
import traceback, sys
_regex = re.compile('\[\[(.+?)\]\]')
@ -108,9 +110,13 @@ 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)
@ -173,7 +179,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