comparison wsgraph/web.py @ 6:259210f2e029

more formatter stubbing
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Dec 2012 13:48:11 -0800
parents 9d5a8c90c482
children 9016b126aa87
comparison
equal deleted inserted replaced
5:9d5a8c90c482 6:259210f2e029
11 GRAPH = 0 11 GRAPH = 0
12 NODE = 1 12 NODE = 1
13 EDGE = 2 13 EDGE = 2
14 14
15 # XXX stubbing hacks 15 # XXX stubbing hacks
16 def JSONFormatter(**kwargs): 16 def JSONFormatter(node, graph, request):
17 return json.dumps(kwargs, sort_keys=True) 17 return json.dumps(graph.node(node), sort_keys=True)
18 def JSONGraphFormatter(graph): 18 def JSONGraphFormatter(graph, request):
19 return json.dumps({'nodes': graph.nodes(), 19 return json.dumps({'nodes': graph.nodes(),
20 'edges': graph.edges()}, 20 'edges': graph.edges()},
21 sort_keys=True) 21 sort_keys=True)
22 22
23 class Dispatcher(object): 23 class Dispatcher(object):
76 formatters = {0: { 76 formatters = {0: {
77 } 77 }
78 78
79 A graph formatter takes the following arguments: 79 A graph formatter takes the following arguments:
80 80
81 def sample_graph_formatter(graph, request): 81 def sample_graph_formatter(graph, request):
82
83 A node formatter takes the following arguments:
84
85 def sample_node_formatter(node, graph, request):
86
87 An edge formatter takes the following arguments:
88
89 def sample_edge_formatter(edge, graph, request):
82 90
83 API: 91 API:
84 92
85 ?format=<format> 93 ?format=<format>
86 94