Commits

Andrew Godwin committed 729c431

Initial main thing

  • Participants
  • Parent commits c8b6fcd

Comments (0)

Files changed (1)

+
+from lxml.etree import fromstring
+from werkzeug import Request, Response
+from werkzeug.exceptions import HTTPException, MethodNotAllowed, BadRequest
+
+class Application(object):
+    
+    @Request.application
+    def __call__(self, request):
+        try:
+            if hasattr(self, request.method):
+                return getattr(self, request.method)(request)
+            else:
+                raise MethodNotAllowed(["OPTIONS", "PROPFIND"])
+        except HTTPException, e:
+            return e
+    
+    def OPTIONS(self, request):
+        return Response(headers = {
+            "Allow": "OPTIONS,GET,HEAD,POST,DELETE,TRACE,PROPFIND,PROPPATCH,COPY,MOVE,LOCK,UNLOCK,CHECKOUT"
+        })
+    
+    def PROPFIND(self, request):
+        # Do they want the properties of the overall repo?
+        data = request.input_stream.read(request.content_length)
+        tree = fromstring(data)
+        if request.path == "/":
+            vcc = "/!svn/vcc/default"
+            uuid = "00000000-80c4-4579-810c-ce57b7db7bfe"
+            response = """<?xml version="1.0" encoding="utf-8"?>
+<D:multistatus xmlns:D="DAV:" xmlns:ns1="http://subversion.tigris.org/xmlns/dav/" xmlns:ns0="DAV:">
+<D:response xmlns:lp1="DAV:" xmlns:lp2="http://subversion.tigris.org/xmlns/dav/">
+<D:href>/</D:href>
+<D:propstat>
+<D:prop>
+<lp1:version-controlled-configuration><D:href>/!svn/vcc/default</D:href></lp1:version-controlled-configuration>
+<lp1:resourcetype><D:collection/></lp1:resourcetype>
+<lp2:baseline-relative-path/>
+<lp2:repository-uuid></lp2:repository-uuid>
+</D:prop>
+<D:status>HTTP/1.1 200 OK</D:status>
+</D:propstat>
+</D:response>
+</D:multistatus>
+"""
+        else:
+            raise BadRequest()
+        return Response(response, status = 207)
+
+if __name__ == "__main__":
+    from werkzeug import run_simple
+    run_simple('localhost', 8080, Application())