Beispiel #1
0
    def mkdtemp(self, prefix):
        """
        Creates a new directory in the document root and returns its path and
        URI.
        """
        path = mkdtemp(prefix=prefix + "_", dir=self.docroot)
        uri  = joinURL("/", url_quote(os.path.basename(path))) + "/"

        return (path, uri)
Beispiel #2
0
 def test_joinURL(self):
     """
     joinURL()
     """
     self.assertEquals(util.joinURL("http://server/foo/"), "http://server/foo/")
     self.assertEquals(util.joinURL("http://server/foo", "/bar"), "http://server/foo/bar")
     self.assertEquals(util.joinURL("http://server/foo", "bar"), "http://server/foo/bar")
     self.assertEquals(util.joinURL("http://server/foo/", "/bar"), "http://server/foo/bar")
     self.assertEquals(util.joinURL("http://server/foo/", "/bar/.."), "http://server/foo")
     self.assertEquals(util.joinURL("http://server/foo/", "/bar/."), "http://server/foo/bar")
     self.assertEquals(util.joinURL("http://server/foo/", "/bar/../"), "http://server/foo/")
     self.assertEquals(util.joinURL("http://server/foo/", "/bar/./"), "http://server/foo/bar/")
     self.assertEquals(util.joinURL("http://server/foo/../", "/bar"), "http://server/bar")
     self.assertEquals(util.joinURL("/foo/"), "/foo/")
     self.assertEquals(util.joinURL("/foo", "/bar"), "/foo/bar")
     self.assertEquals(util.joinURL("/foo", "bar"), "/foo/bar")
     self.assertEquals(util.joinURL("/foo/", "/bar"), "/foo/bar")
     self.assertEquals(util.joinURL("/foo/", "/bar/.."), "/foo")
     self.assertEquals(util.joinURL("/foo/", "/bar/."), "/foo/bar")
     self.assertEquals(util.joinURL("/foo/", "/bar/../"), "/foo/")
     self.assertEquals(util.joinURL("/foo/", "/bar/./"), "/foo/bar/")
     self.assertEquals(util.joinURL("/foo/../", "/bar"), "/bar")
     self.assertEquals(util.joinURL("/foo", "/../"), "/")
     self.assertEquals(util.joinURL("/foo", "/./"), "/foo/")
Beispiel #3
0
    # Generate XML output stream
    #
    request_uri = request.uri
    depth = request.headers.getHeader("depth", "infinity")

    xml_responses = []

    resources = [(self, None)]
    resources.extend(self.findChildren(depth))

    for resource, uri in resources:
        if uri is None:
            uri = normalizeURL(request_uri)
            if self.isCollection() and not uri.endswith("/"): uri += "/"
        else:
            uri = joinURL(request_uri, uri)

        resource_properties = waitForDeferred(resource.listProperties(request))
        yield resource_properties
        resource_properties = resource_properties.getResult()

        if search_properties is "names":
            properties_by_status = {
                responsecode.OK: [propertyName(p) for p in resource_properties]
            }
        else:
            properties_by_status = {
                responsecode.OK        : [],
                responsecode.NOT_FOUND : [],
            }