--- a/web/views/json.py Tue Nov 27 11:27:49 2012 +0100
+++ b/web/views/json.py Tue Nov 27 11:38:03 2012 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -50,14 +50,20 @@
self._cw.form['vid'] = 'jsonexport'
else: # if no vid is specified, use jsonexport
self._cw.form['vid'] = 'jsonexport'
- with anonymized_request(self._cw):
- json_data = super(JsonpController, self).publish(rset)
- if 'callback' in self._cw.form: # jsonp
- json_padding = self._cw.form['callback']
- # use ``application/javascript`` is ``callback`` parameter is
- # provided, let ``application/json`` otherwise
- self._cw.set_content_type('application/javascript')
- json_data = '%s(%s)' % (json_padding, json_data)
+ if self._cw.vreg.config['anonymize-jsonp-queries']:
+ with anonymized_request(self._cw):
+ return self._get_json_data(rset)
+ else:
+ return self._get_json_data(rset)
+
+ def _get_json_data(self, rset):
+ json_data = super(JsonpController, self).publish(rset)
+ if 'callback' in self._cw.form: # jsonp
+ json_padding = self._cw.form['callback']
+ # use ``application/javascript`` is ``callback`` parameter is
+ # provided, let ``application/json`` otherwise
+ self._cw.set_content_type('application/javascript')
+ json_data = '%s(%s)' % (json_padding, json_data)
return json_data