def render_PUT(self, request): name, container_path, fullpath = parse_path(request.path) log.msg("Creating container %s" % fullpath) req_length = request.getHeader("Content-Length") if req_length is None: request.setResponseCode(411) return "" req_length = int(req_length) request.content.seek(0, 0) # process json encoded request body body = request.content.read(req_length) if req_length > 0 else "{}" # a workaround for a buggy curl behavior body = json.loads(body) metadata = {} if "metadata" in body: metadata = body["metadata"] status, vals = container.create_or_update(self.avatar, name, container_path, fullpath, metadata) children = vals["children"].values() if "children" in vals else {} request.setResponseCode(status) request.setHeader("Content-Type", CDMI_CONTAINER) set_common_headers(request) # and a body response_body = { "completionStatus": "Complete", "metadata": metadata, "children": children, "childrenrange": "" if len(children) == 0 else "0-%s" % len(children), } response_body.update(get_common_body(request, vals["uid"], fullpath)) return json.dumps(response_body)
def render_PUT(self, request): name, container_path, fullpath = parse_path(request.path) status, _ = container.create_or_update(self.avatar, name, container_path, fullpath, {}) request.setResponseCode(status) set_common_headers(request, False) return ""