# HG changeset patch # User Jeff Hammel # Date 1355190645 28800 # Node ID f56d27f03e4a54728a87e3bce27d2a8c021ff2aa # Parent 542232f858a91f699c4b66b4d9f79dd2f971f7f8 pretend we are slick but we can be so much slicker diff -r 542232f858a9 -r f56d27f03e4a wsgraph/web.py --- 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()