Factor out the 'json' part from pick
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 07 Mar 2009 00:31:48 +0000
changeset 1703 6d6813e83756
parent 1702 6c69b7cff908
child 1704 b581fdfd6bb1
Factor out the 'json' part from pick Patch by: Sverre Rabbelier
app/soc/views/models/base.py
--- a/app/soc/views/models/base.py	Sat Mar 07 00:31:16 2009 +0000
+++ b/app/soc/views/models/base.py	Sat Mar 07 00:31:48 2009 +0000
@@ -632,6 +632,12 @@
     entities = self._logic.getForFields(filter=filter, limit=1000)
     data = [i.toDict() for i in entities]
 
+    return self.json(request, data)
+
+  def json(self, request, data):
+    """Returns data as a json object.
+    """
+
     to_json = {
         'data': data,
         }
@@ -642,13 +648,15 @@
     template = 'soc/json.html'
 
     response = responses.respond(request, template, context)
+
     # if the browser supports HTTP/1.1
     # post-check and pre-check and no-store for IE7
     response['Cache-Control'] = 'no-store, no-cache, must-revalidate, ' \
         'post-check=0, pre-check=0'
+
     # if the browser supports HTTP/1.0
     response['Pragma'] = 'no-cache'
-    
+
     return response
 
   def _editPost(self, request, entity, fields):