Commits

Marcin Kuzminski committed 8a3a1a5

Fixed simplejson import on python 2.5

  • Participants
  • Parent commits 7903988

Comments (0)

Files changed (1)

File rhodecode/lib/ext_json.py

     _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