예제 #1
0
파일: container.py 프로젝트: livenson/vcdm
    def render_GET(self, request):
        """GET operation corresponds to reading container's data"""
        # parse the request
        _, __, fullpath = parse_path(request.path)

        # contact the backend
        status, vals = container.read(self.avatar, fullpath)

        # create a header
        request.setResponseCode(status)
        request.setHeader("Content-Type", CDMI_CONTAINER)
        set_common_headers(request)

        # and a body
        if status == OK:
            request.setLastModified(float(vals["mtime"]))
            children = vals["children"].values()
            response_body = {
                "completionStatus": "Complete",
                "metadata": vals["metadata"],
                "children": children,
                "childrenrange": "" if len(children) == 0 else "0-%s" % len(children),
                "capabilitiesURI": "/cdmi_capabilities/container",
            }
            response_body.update(get_common_body(request, vals["uid"], fullpath))
            return json.dumps(response_body)
        else:
            return ""
예제 #2
0
파일: container.py 프로젝트: livenson/vcdm
    def render_GET(self, request):
        """GET operation corresponds to reading a container's data."""
        # parse the request
        _, __, fullpath = parse_path(request.path)

        # contact the backend
        status, vals = container.read(self.avatar, fullpath)
        # create a header
        request.setResponseCode(status)
        set_common_headers(request, False)
        if status == OK:
            request.setHeader("Content-Type", "application/json")
            request.setLastModified(float(vals["mtime"]))
            children = None if not "children" in vals else vals["children"].values()
            response_body = {"metadata": vals["metadata"], "children": children}
            return json.dumps(response_body)
        else:
            return ""