Mercurial > kallithea
changeset 2259:90431eda6608
merge with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 11 May 2012 01:33:38 +0200 |
parents | a437a986d399 (current diff) 8a3a1a59a050 (diff) |
children | 0e2792e04bd3 |
files | |
diffstat | 1 files changed, 17 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/ext_json.py Thu May 10 20:27:45 2012 +0200 +++ b/rhodecode/lib/ext_json.py Fri May 11 01:33:38 2012 +0200 @@ -81,22 +81,24 @@ _sj = None -# simplejson not found try out regular json module -import json as _json - +try: + # simplejson not found try out regular json module + import json as _json -# extended JSON encoder for json -class ExtendedEncoder(_json.JSONEncoder): - def default(self, obj): - try: - return _obj_dump(obj) - except NotImplementedError: - pass - return _json.JSONEncoder.default(self, obj) -# monkey-patch JSON encoder to use extended version -_json.dumps = functools.partial(_json.dumps, cls=ExtendedEncoder) -_json.dump = functools.partial(_json.dump, cls=ExtendedEncoder) -stdlib = _json + # extended JSON encoder for json + class ExtendedEncoder(_json.JSONEncoder): + def default(self, obj): + try: + return _obj_dump(obj) + except NotImplementedError: + pass + return _json.JSONEncoder.default(self, obj) + # monkey-patch JSON encoder to use extended version + _json.dumps = functools.partial(_json.dumps, cls=ExtendedEncoder) + _json.dump = functools.partial(_json.dump, cls=ExtendedEncoder) + stdlib = _json +except ImportError: + _json = None # set all available json modules simplejson = _sj