app/soc/views/models/base.py
changeset 2779 db04432cb99a
parent 2747 915fe7338a72
child 2780 0362fb7e3b3c
--- 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" <daniel.m.hans@gmail.com>',
   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
   '"Lennard de Rijk" <ljvderijk@gmail.com>',
   '"Pawel Solyga" <pawel.solyga@gmail.com>',
@@ -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'