diff wsgraph/web.py @ 7:9016b126aa87

WIP
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Dec 2012 13:55:58 -0800
parents 259210f2e029
children 421d5119e324
line wrap: on
line diff
--- a/wsgraph/web.py	Mon Dec 10 13:48:11 2012 -0800
+++ b/wsgraph/web.py	Mon Dec 10 13:55:58 2012 -0800
@@ -13,6 +13,16 @@
 EDGE = 2
 
 # XXX stubbing hacks
+class JSONformatter(object):
+    def __init__(self, sort_keys=True):
+        self.sort_keys = sort_keys
+
+    def format(self, _object):
+        return json.dumps(graph.node(node), sort_keys=self.sort_keys)
+
+    def node(self, node, graph, request):
+        return Response(body=self.format(graph.node(node)))
+
 def JSONFormatter(node, graph, request):
     return json.dumps(graph.node(node), sort_keys=True)
 def JSONGraphFormatter(graph, request):
@@ -94,10 +104,14 @@
 
         """
 
+        # get resource requestor
         segments = self.path_segments(request.path_info)
         if len(segments) not in (0,1,2):
             return exc.HTTPNotFound()
 
+
+        # is resource in the graph? [TODO]
+
         # formatter
         formatter = self.formatters[len(segments)]
         return Response(content_type='text/plain',