]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: add PBURL to the all-peers table on the welcome page
authorBrian Warner <warner@allmydata.com>
Wed, 17 Jan 2007 04:01:18 +0000 (21:01 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 17 Jan 2007 04:01:18 +0000 (21:01 -0700)
src/allmydata/client.py
src/allmydata/web/welcome.xhtml
src/allmydata/webish.py

index 0fe2c7e67ee74419c525c8ed883e3a6ccc9750eb..418016959302a61e29c58a65be260232ca923aef 100644 (file)
@@ -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]
 
index 7adb96ae37979e6454fdb01f1896e64bf32d1773..d162a01fc0952711b14b2c5448e4aac306f006d4 100644 (file)
   <tr n:pattern="header">
     <td>PeerID</td>
     <td>Connected?</td>
+    <td>PBURL</td>
   </tr>
   <tr n:pattern="item" n:render="row">
     <td><tt><n:slot name="peerid"/></tt></td>
     <td><n:slot name="connected"/></td>
+    <td><n:slot name="pburl"/></td>
   </tr>
   <tr n:pattern="empty"><td>no peers!</td></tr>
 </table>
index d0569c9cef51224b1fdb0100cdef62ae9f37d51e..27332217ded5dcca25b4348e0be4ea99ab7ece1b 100644 (file)
@@ -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