From a443631f117abd8eefe051d58880649a89a0f7d6 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 21 Jan 2013 16:42:42 -0600 Subject: [PATCH] fixed IS_JSON, thanks Alan --- VERSION | 2 +- gluon/validators.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 874f6048..b751aea4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.01.21.14.12.24 +Version 2.4.1-alpha.2+timestamp.2013.01.21.16.42.00 diff --git a/gluon/validators.py b/gluon/validators.py index 276ed395..fc0600f1 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -328,12 +328,17 @@ class IS_JSON(Validator): self.error_message = error_message def __call__(self, value): + if value is None: + return None try: - simplejson.loads(value) - return (value, None) + return (simplejson.loads(value), None) except JSONErrors: - pass - return (value, translate(self.error_message)) + return (value, translate(self.error_message)) + + def formatter(self,value): + if value is None: + return None + return simplejson.dumps(value) class IS_IN_SET(Validator):