From 8d7f6b7b7ffb7c174a20f02e28279af8934a4a14 Mon Sep 17 00:00:00 2001 From: Michele Comitini Date: Mon, 22 Jul 2013 14:53:42 +0200 Subject: [PATCH 1/3] improved json validator to output meaningful error --- gluon/validators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gluon/validators.py b/gluon/validators.py index b7122633..09fe6dc0 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -355,11 +355,11 @@ class IS_JSON(Validator): return None try: if self.native_json: - simplejson.dumps(value) # raises error in case of malformed json + simplejson.loads(value) # raises error in case of malformed json return (value, None) # the serialized value is not passed return (simplejson.loads(value), None) - except JSONErrors: - return (value, translate(self.error_message)) + except JSONErrors, e: + return (value, translate(self.error_message) + ': '+ e.message) def formatter(self,value): if value is None: From 839c3fbeff72ef579021e029b781e3ae28c84bf4 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 22 Jul 2013 09:13:23 -0500 Subject: [PATCH 2/3] fixed issue 1602 again, thanks Alan --- VERSION | 2 +- gluon/dal.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index ace6c9b8..cd0c10de 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.22.04.48.04 +Version 2.6.0-development+timestamp.2013.07.22.09.12.34 diff --git a/gluon/dal.py b/gluon/dal.py index c49c847e..bccd14aa 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -4324,10 +4324,10 @@ class DatabaseStoredFile: try: if db.executesql(query): return True - except IOError, e: + except Exception: # no web2py_filesystem found? - LOGGER.error("Could not retrieve %s. %s" % (filename, e)) - pass + tb = traceback.format_exc() + LOGGER.error("Could not retrieve %s\n%s" % (filename, tb)) return False From 44985f007652fa68ce319e4e83b0b9482a68f6bb Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 22 Jul 2013 14:52:53 -0500 Subject: [PATCH 3/3] removed non-translatable json error --- VERSION | 2 +- gluon/validators.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index cd0c10de..f8a2f479 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.22.09.12.34 +Version 2.6.0-development+timestamp.2013.07.22.14.51.29 diff --git a/gluon/validators.py b/gluon/validators.py index 09fe6dc0..21d94a2f 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -359,7 +359,7 @@ class IS_JSON(Validator): return (value, None) # the serialized value is not passed return (simplejson.loads(value), None) except JSONErrors, e: - return (value, translate(self.error_message) + ': '+ e.message) + return (value, translate(self.error_message)) def formatter(self,value): if value is None: