mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 03:06:41 +00:00
more ctx -> req
This commit is contained in:
parent
79c3f919ba
commit
c2ff7e260b
@ -203,8 +203,7 @@ def plural(sequence_or_length):
|
||||
return ""
|
||||
return "s"
|
||||
|
||||
def text_plain(text, ctx):
|
||||
req = IRequest(ctx)
|
||||
def text_plain(text, req):
|
||||
req.setHeader("content-type", "text/plain")
|
||||
req.setHeader("content-length", b"%d" % len(text))
|
||||
return text
|
||||
|
@ -207,14 +207,14 @@ class FileNodeHandler(Resource, ReplaceMeMixin, object):
|
||||
self.parentnode.get_metadata_for(self.name))
|
||||
else:
|
||||
d.addCallback(lambda ignored: None)
|
||||
d.addCallback(lambda md: FileJSONMetadata(ctx, self.node, md))
|
||||
d.addCallback(lambda md: FileJSONMetadata(req, self.node, md))
|
||||
return d
|
||||
if t == "info":
|
||||
return MoreInfo(self.node)
|
||||
if t == "uri":
|
||||
return FileURI(ctx, self.node)
|
||||
return FileURI(req, self.node)
|
||||
if t == "readonly-uri":
|
||||
return FileReadOnlyURI(ctx, self.node)
|
||||
return FileReadOnlyURI(req, self.node)
|
||||
raise WebError("GET file: bad t=%s" % t)
|
||||
|
||||
def render_HEAD(self, req):
|
||||
@ -311,7 +311,7 @@ class FileNodeHandler(Resource, ReplaceMeMixin, object):
|
||||
d.addCallback(self._maybe_literal, CheckResultsRenderer)
|
||||
return d
|
||||
|
||||
def render_DELETE(self, ctx):
|
||||
def render_DELETE(self, req):
|
||||
assert self.parentnode and self.name
|
||||
d = self.parentnode.delete(self.name)
|
||||
d.addCallback(lambda res: self.node.get_uri())
|
||||
@ -491,12 +491,12 @@ class FileDownloader(Resource, object):
|
||||
# We haven't written anything yet, so we can provide a
|
||||
# sensible error message.
|
||||
eh = MyExceptionHandler()
|
||||
eh.renderHTTP_exception(ctx, f)
|
||||
eh.renderHTTP_exception(req, f)
|
||||
d.addCallbacks(_finished, _error)
|
||||
return req.deferred
|
||||
|
||||
|
||||
def FileJSONMetadata(ctx, filenode, edge_metadata):
|
||||
def FileJSONMetadata(req, filenode, edge_metadata):
|
||||
rw_uri = filenode.get_write_uri()
|
||||
ro_uri = filenode.get_readonly_uri()
|
||||
data = ("filenode", get_filenode_metadata(filenode))
|
||||
@ -510,16 +510,16 @@ def FileJSONMetadata(ctx, filenode, edge_metadata):
|
||||
if edge_metadata is not None:
|
||||
data[1]['metadata'] = edge_metadata
|
||||
|
||||
return text_plain(json.dumps(data, indent=1) + "\n", ctx)
|
||||
return text_plain(json.dumps(data, indent=1) + "\n", req)
|
||||
|
||||
def FileURI(ctx, filenode):
|
||||
return text_plain(filenode.get_uri(), ctx)
|
||||
def FileURI(req, filenode):
|
||||
return text_plain(filenode.get_uri(), req)
|
||||
|
||||
def FileReadOnlyURI(ctx, filenode):
|
||||
def FileReadOnlyURI(req, filenode):
|
||||
if filenode.is_readonly():
|
||||
return text_plain(filenode.get_uri(), ctx)
|
||||
return text_plain(filenode.get_readonly_uri(), ctx)
|
||||
return text_plain(filenode.get_uri(), req)
|
||||
return text_plain(filenode.get_readonly_uri(), req)
|
||||
|
||||
class FileNodeDownloadHandler(FileNodeHandler):
|
||||
def childFactory(self, ctx, name):
|
||||
def childFactory(self, req, name):
|
||||
return FileNodeDownloadHandler(self.client, self.node, name=name)
|
||||
|
Loading…
Reference in New Issue
Block a user