[MERGE] safe_eval, reports: improve logging and exception handling
bzr revid: odo@openerp.com-20100622093238-xy4dwtg80ikf0nhz
This commit is contained in:
@@ -63,7 +63,10 @@ def _child_get(node, self=None, tagname=None):
|
||||
if n.get('rml_except', False):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except GeneratorExit:
|
||||
continue
|
||||
except:
|
||||
logging.getLogger('report').exception()
|
||||
continue
|
||||
if n.get('rml_tag'):
|
||||
try:
|
||||
@@ -72,7 +75,10 @@ def _child_get(node, self=None, tagname=None):
|
||||
n2.tag = tag
|
||||
n2.attrib.update(attr)
|
||||
yield n2
|
||||
except GeneratorExit:
|
||||
yield n
|
||||
except:
|
||||
logging.getLogger('report').exception()
|
||||
yield n
|
||||
else:
|
||||
yield n
|
||||
@@ -81,7 +87,10 @@ def _child_get(node, self=None, tagname=None):
|
||||
if self and self.localcontext and n.get('rml_except'):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except GeneratorExit:
|
||||
continue
|
||||
except:
|
||||
logging.getLogger('report').exception()
|
||||
continue
|
||||
if self and self.localcontext and n.get('rml_tag'):
|
||||
try:
|
||||
@@ -91,7 +100,10 @@ def _child_get(node, self=None, tagname=None):
|
||||
n2.attrib.update(attr or {})
|
||||
yield n2
|
||||
tagname = ''
|
||||
except GeneratorExit:
|
||||
pass
|
||||
except:
|
||||
logging.getLogger('report').exception()
|
||||
pass
|
||||
if (tagname is None) or (n.tag==tagname):
|
||||
yield n
|
||||
|
||||
@@ -192,7 +192,7 @@ class rml_parse(object):
|
||||
return text.strip()
|
||||
|
||||
def removeParentNode(self, tag=None):
|
||||
raise Exception('Skip')
|
||||
raise GeneratorExit('Skip')
|
||||
|
||||
def set_html_image(self,id,model=None,field=None,context=None):
|
||||
if not id :
|
||||
|
||||
@@ -86,8 +86,14 @@ def test_expr(expr, allowed_codes, mode="eval"):
|
||||
return the compiled code object. Otherwise raise a ValueError.
|
||||
"""
|
||||
try:
|
||||
if mode == 'eval':
|
||||
expr = expr.strip()
|
||||
code_obj = compile(expr, "", mode)
|
||||
except:
|
||||
except SyntaxError:
|
||||
raise
|
||||
except TypeError:
|
||||
raise
|
||||
except Exception, e:
|
||||
raise ValueError("%s is not a valid expression" % expr)
|
||||
for code in _get_opcodes(code_obj):
|
||||
if code not in allowed_codes:
|
||||
|
||||
Reference in New Issue
Block a user