openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #01892
[Merge] lp:~red15/openobject-client-web/fix-json into lp:openobject-client-web
Niels Huylebroeck has proposed merging lp:~red15/openobject-client-web/fix-json into lp:openobject-client-web.
Requested reviews:
OpenERP SA's Web Client R&D (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~red15/openobject-client-web/fix-json/+merge/45137
Fixes old 2.5 style dependency (makes it hard/illogical when run on python2.6 hosts)
This fixes it by using import json in a try: except block as is also done on the openerp-server itself.
--
https://code.launchpad.net/~red15/openobject-client-web/fix-json/+merge/45137
Your team OpenERP SA's Web Client R&D is requested to review the proposed merge of lp:~red15/openobject-client-web/fix-json into lp:openobject-client-web.
=== modified file 'openobject/tools/_expose.py'
--- openobject/tools/_expose.py 2010-12-02 14:21:42 +0000
+++ openobject/tools/_expose.py 2011-01-04 16:22:16 +0000
@@ -30,7 +30,10 @@
import re
import cherrypy
-import simplejson
+try:
+ import json
+except ImportError:
+ import simplejson as json
from mako.template import Template
from mako.lookup import TemplateLookup
@@ -191,12 +194,12 @@
res = func(*args, **kw)
if format == 'json' or (allow_json and 'allow_json' in cherrypy.request.params):
cherrypy.response.headers['Content-Type'] = 'text/javascript'
- return simplejson.dumps(res)
+ return json.dumps(res)
elif format == 'jsonp' and 'callback' in cherrypy.request.params:
cherrypy.response.headers['Content-Type'] = 'text/javascript'
return '%(function)s(%(data)s);' % {
'function': cherrypy.request.params['callback'],
- 'data': simplejson.dumps(res)
+ 'data': json.dumps(res)
}
cherrypy.response.headers['Content-Type'] = content_type or \
Follow ups