Commits

Anonymous committed 15eaca4

pyRest updated

  • Participants
  • Parent commits 65e2c57

Comments (0)

Files changed (1)

-import cherrypy
+import cherrypy, hgapi
+from collections import namedtuple
 
-def requesthandler(*pathargs, **kwargs):
-    cherrypy.response.status = "500 Server Error"
-    return "Not implemented"
+Response = namedtuple('response', 'status content')
 
+def requesthandler(method, *pathargs, **kwargs):
+    """Main dispatch for calls to PyRest; no framework specific 
+    code to be present after this point"""
+
+    if not method == 'get':
+        return Response('500 Server Error', 'Not implemented')
+
+    repo = hgapi.Repo('.')
+    return Response('200 Ok', repo.hg_id())
+    
 
 class PyRest(object):
 
     def index(self, *args, **kwargs):
-        return requesthandler(*args, **kwargs)
+        method = cherrypy.request.method.lower()
+        response = requesthandler(method, *args, **kwargs)
+        cherrypy.response.status = response.status
+        return response.content
     index.exposed = True