Mercurial > hg > WSGraph
diff wsgraph/web.py @ 21:f56d27f03e4a
pretend we are slick but we can be so much slicker
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Dec 2012 17:50:45 -0800 |
parents | 542232f858a9 |
children | a401bf63c938 |
line wrap: on
line diff
--- a/wsgraph/web.py Mon Dec 10 17:46:07 2012 -0800 +++ b/wsgraph/web.py Mon Dec 10 17:50:45 2012 -0800 @@ -40,21 +40,13 @@ class Dispatcher(object): def __init__(self, graph, - graph_formatters=None, - node_formatters=None, - edge_formatters=None, + graph_formatters, + node_formatters, + edge_formatters, require_auth=False): self.graph = graph self.require_auth = require_auth - # use JSON formatter by default - if graph_formatters is None: - graph_formatters = {None: JSONGraphFormatter} - if node_formatters is None: - node_formatters = {None: JSONFormatter} - if edge_formatters is None: - edge_formatters = {None: JSONFormatter} - # view formatters self.formatters = {GRAPH: graph_formatters, NODE: node_formatters, @@ -166,10 +158,13 @@ graph = MemoryCache() # example formatter(s) - # TODO + formatter = JSONformatter(content_type='text/plain') + _formatters = {} + _formatters = dict([('%s_formatters' % i, {None: getattr(formatter, i)}) + for i in 'graph', 'node', 'edge']) # WSGI app - app = Dispatcher(graph=graph) + app = Dispatcher(graph=graph, **_formatters) server = simple_server.make_server(host='0.0.0.0', port=options.port, app=app) print 'http://localhost:%s/' % options.port server.serve_forever()