From 0dd7b27b569a3b6501d60ad5571b822c978a857f Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 8 Nov 2019 14:12:08 -0500 Subject: [PATCH 1/2] news fragment --- newsfragments/3264.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3264.minor diff --git a/newsfragments/3264.minor b/newsfragments/3264.minor new file mode 100644 index 000000000..e69de29bb From c80c753e5dab71f4d803c69dec422b95fc9e5105 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Fri, 8 Nov 2019 14:12:38 -0500 Subject: [PATCH 2/2] Late bind storage so init_storage can run after init_web --- src/allmydata/web/root.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 0e241cfc3..4ededb8c9 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -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):