Reduce fatal exception to a warning for 'eval'
authorP. Christeas <p_christ@hol.gr>
Fri, 26 Sep 2008 07:28:27 +0000 (10:28 +0300)
committerP. Christeas <p_christ@hol.gr>
Fri, 26 Sep 2008 07:28:27 +0000 (10:28 +0300)
If the data xml contains an eval expression that does not compute,
the convert procedure would throw an exception all the way up. Now,
catch that and only display a warning.

Hopefully, this warning will be fixed to contain more useful info
about its nature.

bzr revid: p_christ@hol.gr-20080926072827-41i7lihw2i9uaisk

bin/tools/convert.py

index 0b07312..24a14c8 100644 (file)
@@ -106,7 +106,12 @@ def _eval_xml(self,node, pool, cr, uid, idref, context=None):
                         all_timezones=[]
                     pytz=pytzclass()
                 idref['pytz'] = pytz
-                return eval(a_eval, idref)
+               try:
+                       return eval(a_eval, idref)
+               except:
+                       logger = netsvc.Logger()
+                       logger.notifyChannel("init", netsvc.LOG_WARNING, 'could eval(%s) for %s in %s, please get back and fix it!' % (a_eval,node.getAttribute('name'),context))
+                       return ""
             if t == 'xml':
                 def _process(s, idref):
                     m = re.findall('[^%]%\((.*?)\)[ds]', s)