]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: show vdrive and introducer connectedness separately
authorBrian Warner <warner@lothar.com>
Sun, 10 Jun 2007 04:03:57 +0000 (21:03 -0700)
committerBrian Warner <warner@lothar.com>
Sun, 10 Jun 2007 04:03:57 +0000 (21:03 -0700)
Also don't offer a link to the vdrive webpages if we don't have a vdrive.furl

src/allmydata/client.py
src/allmydata/introducer.py
src/allmydata/web/welcome.xhtml
src/allmydata/webish.py

index f25ed962a40795ae4b3a833bce698a0ada87c9f5..09acfefc2665783c8609aca532b1d258d9627940 100644 (file)
@@ -36,7 +36,7 @@ class Client(node.Node, Referenceable):
         node.Node.__init__(self, basedir)
         self.my_furl = None
         self.introducer_client = None
-        self.connected_to_vdrive = False
+        self._connected_to_vdrive = False
         self.add_service(StorageServer(os.path.join(basedir, self.STOREDIR)))
         self.add_service(Uploader())
         self.add_service(Downloader())
@@ -113,12 +113,12 @@ class Client(node.Node, Referenceable):
     def _got_vdrive(self, vdrive_root):
         # vdrive_root implements RIMutableDirectoryNode
         self.log("connected to vdrive")
-        self.connected_to_vdrive = True
+        self._connected_to_vdrive = True
         self.getServiceNamed("vdrive").set_root(vdrive_root)
         if "webish" in self.namedServices:
             self.getServiceNamed("webish").set_root_dirnode(vdrive_root)
         def _disconnected():
-            self.connected_to_vdrive = False
+            self._connected_to_vdrive = False
         vdrive_root.notifyOnDisconnect(_disconnected)
 
     def remote_get_versions(self):
@@ -137,6 +137,8 @@ class Client(node.Node, Referenceable):
 
 
     def get_all_peerids(self):
+        if not self.introducer_client:
+            return []
         return self.introducer_client.connections.iterkeys()
 
     def get_permuted_peers(self, key):
@@ -150,3 +152,11 @@ class Client(node.Node, Referenceable):
             results.append((permuted, peerid, connection))
         results.sort()
         return results
+
+    def connected_to_vdrive(self):
+        return self._connected_to_vdrive
+
+    def connected_to_introducer(self):
+        if self.introducer_client:
+            return self.introducer_client.connected_to_introducer()
+        return False
index 96dd875b2283fcba125bb8c1ab304ea4e8a40f30..ccda1e71b04412d1216cfaf7c557739308d1dffe 100644 (file)
@@ -39,6 +39,7 @@ class IntroducerClient(service.Service, Referenceable):
 
         self.connections = {} # k: nodeid, v: ref
         self.reconnectors = {} # k: FURL, v: reconnector
+        self._connected = False
 
         self.connection_observers = observer.ObserverList()
 
@@ -94,12 +95,19 @@ class IntroducerClient(service.Service, Referenceable):
 
     def _got_introducer(self, introducer):
         self.log(" introducing ourselves: %s, %s" % (self, self.my_furl))
+        self._connected = True
         d = introducer.callRemote("hello",
                              node=self,
                              furl=self.my_furl)
+        introducer.notifyOnDisconnect(self._disconnected)
+
+    def _disconnected(self):
+        self._connected = False
 
     def notify_on_new_connection(self, cb):
         """Register a callback that will be fired (with nodeid, rref) when
         a new connection is established."""
         self.connection_observers.subscribe(cb)
 
+    def connected_to_introducer(self):
+        return self._connected
index c9e3116bad88d780a067e33487c498c8e0544937..b4c3b94f53435b7b1cec5dfe61cd698c97016cc6 100644 (file)
 
 <h1>Welcome To AllMyData! (tahoe2)</h1>
 
-<p>To view the global shared filestore, <a href="../vdrive">Click Here!</a></p>
+<div n:render="vdrive" />
 
 <h2>Grid Status</h2>
 
 <div>My nodeid: <span n:render="string" n:data="my_nodeid" /></div>
 <div>Introducer: <span n:render="string" n:data="introducer_furl" /></div>
 <div>Connected to introducer?: <span n:render="string" n:data="connected_to_introducer" /></div>
+<div>Connected to vdrive?: <span n:render="string" n:data="connected_to_vdrive" /></div>
 <div>Known+Connected Peers: <span n:render="string" n:data="num_peers" /></div>
 
 <div>
index 794a6b766ba7594216c18b54d126b60a24b91b59..daf6cdf0b4304297d1a189d6359fb62271883697 100644 (file)
@@ -33,7 +33,11 @@ class Welcome(rend.Page):
     def data_introducer_furl(self, ctx, data):
         return IClient(ctx).introducer_furl
     def data_connected_to_introducer(self, ctx, data):
-        if IClient(ctx).connected_to_vdrive:
+        if IClient(ctx).connected_to_introducer():
+            return "yes"
+        return "no"
+    def data_connected_to_vdrive(self, ctx, data):
+        if IClient(ctx).connected_to_vdrive():
             return "yes"
         return "no"
     def data_num_peers(self, ctx, data):
@@ -54,6 +58,13 @@ class Welcome(rend.Page):
         ctx.fillSlots("peerid", nodeid_a)
         return ctx.tag
 
+    def render_vdrive(self, ctx, data):
+        if IClient(ctx).connected_to_vdrive():
+            return T.p["To view the global shared filestore, ",
+                       T.a(href="../vdrive")["Click Here!"],
+                       ]
+        return T.p["vdrive.furl not specified, no vdrive available."]
+
     # this is a form where users can download files by URI
 
     def bind_download(self, ctx):