explicitly save refs to webish and operations (instead of using Service methods)

This commit is contained in:
meejah 2019-08-24 12:31:08 -06:00
parent 747e9af19f
commit 9050fdcea6
3 changed files with 16 additions and 4 deletions

View File

@ -496,6 +496,12 @@ class _Client(node.Node, pollmixin.PollMixin):
def get_long_tubid(self):
return idlib.nodeid_b2a(self.nodeid)
def get_web_service(self):
"""
:return: a reference to our web server
"""
return self.getServiceNamed("webish")
def _init_permutation_seed(self, ss):
seed = self.config.get_config_from_file("permutation-seed")
if not seed:

View File

@ -62,7 +62,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
self.node = node
self.parentnode = parentnode
self.name = name
self._operations = client.getServiceNamed("webish").getServiceNamed("operations")
self._operations = client.get_web_service().get_operations()
def childFactory(self, ctx, name):
name = name.decode("utf-8")

View File

@ -168,9 +168,9 @@ class WebishServer(service.MultiService):
# If set, clock is a twisted.internet.task.Clock that the tests
# use to test ophandle expiration.
operations = OphandleTable(clock)
operations.setServiceParent(self)
self.root.putChild("operations", operations)
self._operations = OphandleTable(clock)
self._operations.setServiceParent(self)
self.root.putChild("operations", self._operations)
def buildServer(self, webport, nodeurl_path, staticdir):
self.webport = webport
@ -241,6 +241,12 @@ class WebishServer(service.MultiService):
# who knows, probably some weirdo future version of Twisted
self._started.errback(AssertionError("couldn't find out the scheme or port for the web-API server"))
def get_operations(self):
"""
:return: a reference to our "active operations" tracker
"""
return self._operations
class IntroducerWebishServer(WebishServer):
def __init__(self, introducer, webport, nodeurl_path=None, staticdir=None):