diff wsgraph/web.py @ 4:c7170cab1184

more RESTful stubbing
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 09 Dec 2012 20:10:07 -0800
parents 42f484880808
children 9d5a8c90c482
line wrap: on
line diff
--- 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=<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__':