[Booki-dev] Comments on Booki
Alexandre Quessy
alexandre at quessy.net
Sun Sep 19 02:42:37 PDT 2010
Hello!
2010/9/19 Douglas Bagnall <douglas at paradise.net.nz>:
>> * you don't need python-simplejson if you are using python 2.6 or
>> above. Just use the "json" module.
>
> The booki server runs lenny which has 2.5, so simplejson is needed.
> I think the usual way to deal with this is something like:
>
> try:
> import json
> except ImportError:
> import simplejson as json
>
> which Booki uses in some places but not everywhere. It breaks if the
> entirely unrelated python-json is installed, but that is rare.
Here is the code snippet I used when I was supporting older Python versions:
try:
import json # python 2.6
except ImportError:
import simplejson as json # python 2.4 to 2.5
try:
_tmp = json.loads
except AttributeError:
import warnings
import sys
warnings.warn("Use simplejson, not the old json module.")
sys.modules.pop('json') # get rid of the bad json module
import simplejson as json
--
Alexandre Quessy
http://alexandre.quessy.net/
More information about the Booki-dev
mailing list