Merge pull request #666 from tahoe-lafs/3264.late-bind-storage-for-web

Late bind storage child for the web api
This commit is contained in:
Jean-Paul Calderone 2019-11-08 19:02:57 -05:00 committed by GitHub
commit f0d32a5123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

0
newsfragments/3264.minor Normal file
View File

View File

@ -196,12 +196,6 @@ class Root(MultiFormatPage):
rend.Page.__init__(self, client)
self.client = client
self.now_fn = now_fn
try:
s = client.getServiceNamed("storage")
except KeyError:
s = None
self.putChild("storage", storage.StorageStatus(s, self.client.nickname))
self.putChild("uri", URIHandler(client))
self.putChild("cap", URIHandler(client))
@ -237,6 +231,16 @@ class Root(MultiFormatPage):
# the Helper isn't attached until after the Tub starts, so this child
# needs to created on each request
return status.HelperStatus(self.client.helper)
if path == "storage":
# Storage isn't initialized until after the web hierarchy is
# constructed so this child needs to be created later than
# `__init__`.
try:
storage_server = self.client.getServiceNamed("storage")
except KeyError:
storage_server = None
return storage.StorageStatus(storage_server, self.client.nickname)
# FIXME: This code is duplicated in root.py and introweb.py.
def data_rendered_at(self, ctx, data):