# HG changeset patch # User Jeff Hammel # Date 1355112607 28800 # Node ID c7170cab1184c92037d0c17180d7295ebfda85ed # Parent 42f4848808089e64115aca5cb22508e4dee102b9 more RESTful stubbing diff -r 42f484880808 -r c7170cab1184 wsgraph/web.py --- a/wsgraph/web.py Sun Dec 09 14:51:23 2012 -0800 +++ b/wsgraph/web.py Sun Dec 09 20:10:07 2012 -0800 @@ -7,6 +7,10 @@ import json from webob import Request, Response, exc +GRAPH = 0 +NODE = 1 +EDGE = 2 + def JSONFormatter(**kwargs): return json.dumps(kwargs, sort_keys=True) @@ -55,6 +59,10 @@ formatters = {0: { } + A graph formatter takes the following arguments: + + def sample_graph_formatter(graph, request): + API: ?format= @@ -62,6 +70,8 @@ """ segments = self.path_segments(request) + if len(segments) not in (0,1,2): + return exc.HTTPNotFound() # formatter formatter = self.formatters[len(segments)] @@ -77,14 +87,14 @@ ?update : """ - return exc.HTTPSeeOther('/') # TODO: /path/to/self + return exc.HTTPSeeOther(location='/') # TODO: /path/to/self def HEAD(self, request): """respond to a HEAD request""" raise NotImplementedError def OPTIONS(self, request): - raise NotImplementedError + return Response() # TODO: Allow=', '.join(self.methods); Content-Length=0 if __name__ == '__main__':