Mercurial > hg > WSGraph
diff wsgraph/web.py @ 23:24d57daaca21
well, now the request dispatches
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Dec 2012 21:15:24 -0800 |
parents | a401bf63c938 |
children |
line wrap: on
line diff
--- a/wsgraph/web.py Mon Dec 10 17:51:50 2012 -0800 +++ b/wsgraph/web.py Mon Dec 10 21:15:24 2012 -0800 @@ -34,7 +34,7 @@ def graph(self, request, graph): return Response(content_type=self.content_type, - body='hello? is it me you\'re looking for?') + body = self.format(graph())) class Dispatcher(object): @@ -76,6 +76,13 @@ segments = [] return segments + + def formatter(self, rank, request): + """returns the formatter for a request""" + formatters = self.formatters[rank] + format = request.GET.get('format') + return formatters.get(format, formatters[None]) + # HTTP methods def GET(self, request): @@ -117,10 +124,8 @@ return exc.HTTPNotFound() # formatter - formatter = self.formatters[len(segments)] + formatter = self.formatter(rank, request) return formatter(request, self.graph, *segments) - return Response(content_type='text/plain', - body=content) def POST(self, request): """ @@ -131,6 +136,10 @@ ?update : """ + # check authorization + if self.require_auth: + raise NotImplementedError + return exc.HTTPSeeOther(location='/') # TODO: /path/to/self def HEAD(self, request):