comparison wsgraph/web.py @ 20:542232f858a9

rearrange this all around for argument order
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Dec 2012 17:46:07 -0800
parents 8162dc8dd93a
children f56d27f03e4a
comparison
equal deleted inserted replaced
19:8162dc8dd93a 20:542232f858a9
22 22
23 def format(self, instance): 23 def format(self, instance):
24 """front-end to json.dumps""" 24 """front-end to json.dumps"""
25 return json.dumps(instance, sort_keys=self.sort_keys) 25 return json.dumps(instance, sort_keys=self.sort_keys)
26 26
27 def node(self, node, graph, request): 27 def node(self, request, graph, node):
28 return Response(content_type=self.content_type, 28 return Response(content_type=self.content_type,
29 body=self.format(graph.node(node))) 29 body=self.format(graph.node(node)))
30 30
31 def edge(self, node1, node2, graph, request): 31 def edge(self, request, graph, node1, node2):
32 return Response(content_type=self.content_type, 32 return Response(content_type=self.content_type,
33 body=self.format(graph.edge(node))) 33 body=self.format(graph.edge(node1, node2)))
34 34
35 def graph(self, graph, request): 35 def graph(self, request, graph):
36 return Response(content_type=self.content_type, 36 return Response(content_type=self.content_type,
37 body='hello? is it me you\'re looking for?') 37 body='hello? is it me you\'re looking for?')
38
38 39
39 class Dispatcher(object): 40 class Dispatcher(object):
40 41
41 def __init__(self, graph, 42 def __init__(self, graph,
42 graph_formatters=None, 43 graph_formatters=None,
122 if tuple(segments) not in self.graph: 123 if tuple(segments) not in self.graph:
123 return exc.HTTPNotFound() 124 return exc.HTTPNotFound()
124 125
125 # formatter 126 # formatter
126 formatter = self.formatters[len(segments)] 127 formatter = self.formatters[len(segments)]
127 return formatter(*segments, self.graph, request) 128 return formatter(request, self.graph, *segments)
128 return Response(content_type='text/plain', 129 return Response(content_type='text/plain',
129 body=content) 130 body=content)
130 131
131 def POST(self, request): 132 def POST(self, request):
132 """ 133 """