From: Brian Warner Date: Wed, 17 Jan 2007 04:01:18 +0000 (-0700) Subject: webish: add PBURL to the all-peers table on the welcome page X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~363 X-Git-Url: https://git.rkrishnan.org/zeppelin?a=commitdiff_plain;h=8e03d19ccc249cac396a1395f134a8ea82fcad3c;p=tahoe-lafs%2Ftahoe-lafs.git webish: add PBURL to the all-peers table on the welcome page --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 0fe2c7e6..41801695 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -29,6 +29,7 @@ class Client(node.Node, Referenceable): node.Node.__init__(self, basedir) self.queen = None # self.queen is either None or a RemoteReference self.all_peers = set() + self.peer_pburls = {} self.connections = {} self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR))) self.add_service(Uploader()) @@ -105,6 +106,7 @@ class Client(node.Node, Referenceable): self.log("weird, I already had an entry for them") return self.all_peers.add(nodeid) + self.peer_pburls[nodeid] = pburl if nodeid not in self.connections: d = self.tub.getReference(pburl) def _got_reference(ref, which_nodeid): @@ -122,6 +124,8 @@ class Client(node.Node, Referenceable): self.all_peers.remove(nodeid) else: self.log("weird, I didn't have an entry for them") + if nodeid in self.peer_pburls: + del self.peer_pburls[nodeid] if nodeid in self.connections: del self.connections[nodeid] diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index 7adb96ae..d162a01f 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -24,10 +24,12 @@ PeerID Connected? + PBURL + no peers! diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index d0569c9c..27332217 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -39,15 +39,25 @@ class Welcome(rend.Page): return len(client.all_peers) def data_num_connected_peers(self, ctx, data): return len(IClient(ctx).connections) + def data_peers(self, ctx, data): - return sorted(IClient(ctx).all_peers) + d = [] + client = IClient(ctx) + for nodeid in sorted(client.all_peers): + if nodeid in client.connections: + connected = "yes" + else: + connected = "no" + pburl = client.peer_pburls[nodeid] + row = (idlib.b2a(nodeid), connected, pburl) + d.append(row) + return d + def render_row(self, ctx, data): - if data in IClient(ctx).connections: - connected = "yes" - else: - connected = "no" - ctx.fillSlots("peerid", idlib.b2a(data)) + nodeid_a, connected, pburl = data + ctx.fillSlots("peerid", nodeid_a) ctx.fillSlots("connected", connected) + ctx.fillSlots("pburl", pburl) return ctx.tag # this is a form where users can download files by URI