# HG changeset patch # User Daniel Hans # Date 1250527403 -7200 # Node ID db04432cb99ae7b9cddf0c8664bfc23abb4b3e4e # Parent 44bb0e89cc1b7ed137c71526e80c9317a1142089 Argument to_json added to json function in Base view. Its value (which should be a boolean) determines if the data should be converted to a JSON object. Therefore if someone has already a JSON string and wants to return it in a HTTP response, he or she may set to_json=False and the object will not be converted. diff -r 44bb0e89cc1b -r db04432cb99a app/soc/views/models/base.py --- a/app/soc/views/models/base.py Mon Aug 17 14:01:13 2009 +0200 +++ b/app/soc/views/models/base.py Mon Aug 17 18:43:23 2009 +0200 @@ -18,6 +18,7 @@ """ __authors__ = [ + '"Daniel Hans" ', '"Sverre Rabbelier" ', '"Lennard de Rijk" ', '"Pawel Solyga" ', @@ -724,15 +725,19 @@ return self.json(request, data) - def json(self, request, data): + def json(self, request, data, to_json=True): """Returns data as a json object. + + Args: + request: the standard Django HTTP request object + data: the data to be sent as a json object + to_json: determines if the data should be converted to a json object """ - to_json = { - 'data': data, - } - - json = simplejson.dumps(to_json) + if to_json: + json = simplejson.dumps({'data': data}) + else: + json = data context = {'json': json} template = 'soc/json.html'