# HG changeset patch # User Jeff Hammel # Date 1355176558 28800 # Node ID 9016b126aa87cc2b1d086215cc135d4c5ff3706a # Parent 259210f2e029a6145478ebeb05fe88b2270c6f06 WIP diff -r 259210f2e029 -r 9016b126aa87 wsgraph/web.py --- 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',