Changeset - 8a3a1a59a050
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2012-05-11 01:30:19
marcin@python-works.com
Fixed simplejson import on python 2.5
1 file changed with 17 insertions and 15 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/ext_json.py
Show inline comments
 
@@ -81,22 +81,24 @@ except ImportError:
 
    _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
0 comments (0 inline, 0 general)