diff -r a33402c1aa79 -r 0e3ae19b181a utils.py --- a/utils.py Thu Jul 08 12:54:28 2010 +0200 +++ b/utils.py Thu Jul 08 13:33:40 2010 +0200 @@ -327,12 +327,13 @@ try: # may not be there if cubicweb-web not installed - if sys.version_info < (2,6): + if sys.version_info < (2, 6): import simplejson as json else: import json except ImportError: - pass + json_dumps = None + else: class CubicWebJsonEncoder(json.JSONEncoder): @@ -360,6 +361,9 @@ # just return None in those cases. return None + def json_dumps(value): + return json.dumps(value, cls=CubicWebJsonEncoder) + @deprecated('[3.7] merge_dicts is deprecated') def merge_dicts(dict1, dict2):