dabo Commit
Revision 5686
Date: 2010-02-15 09:13:00 -0800 (Mon, 15 Feb 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5686

Changed:
U   trunk/dabo/lib/__init__.py

Log:
Updated the routine to use the built-in json module when running under Python 
2.6 or later.


Diff:
Modified: trunk/dabo/lib/__init__.py
===================================================================
--- trunk/dabo/lib/__init__.py  2010-02-15 16:59:02 UTC (rev 5685)
+++ trunk/dabo/lib/__init__.py  2010-02-15 17:13:00 UTC (rev 5686)
@@ -20,13 +20,20 @@
 
 
 try:
-       import simplejson
-except:
-       jsonConverter = None
-       def jsonEncode(val):
-               raise ImportError("The simplejson module is not installed")
-       def jsonDecode(val):
-               raise ImportError("The simplejson module is not installed")
+       # cjson is fastest; use that if available.
+       import cjson as json
+except ImportError:
+       try:
+               import simplejson as json
+       except ImportError:
+               # Python 2.6 comes with the json module built-in
+               try:
+                       import json
+               except ImportError:
+                       json = None
+if json:
+       jsonEncode = json.dumps
+       jsonDecode = json.loads
 else:
        import dejavuJSON
        jsonConverter = dejavuJSON.Converter()



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to