From: Brian Warner Date: Fri, 15 Jun 2007 08:33:24 +0000 (-0700) Subject: create a personal (non-shared) vdrive, in addition to the global shared one X-Git-Tag: allmydata-tahoe-0.4.0~38 X-Git-Url: https://git.rkrishnan.org/nxhtml.html?a=commitdiff_plain;h=20dcda4ca7486df554d95e957e1e5cbf093a9bd7;p=tahoe-lafs%2Ftahoe-lafs.git create a personal (non-shared) vdrive, in addition to the global shared one --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index a51cfcdc..bdd9189e 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -28,6 +28,7 @@ class Client(node.Node, Referenceable): GLOBAL_VDRIVE_FURL_FILE = "vdrive.furl" MY_FURL_FILE = "myself.furl" SUICIDE_PREVENTION_HOTLINE_FILE = "suicide_prevention_hotline" + MY_VDRIVE_FURL_FILE = "my_vdrive.furl" # we're pretty narrow-minded right now OLDEST_SUPPORTED_VERSION = allmydata.__version__ @@ -61,6 +62,7 @@ class Client(node.Node, Referenceable): self.global_vdrive_furl = f.read().strip() f.close() #self.add_service(VDrive()) + self._my_vdrive = None hotline_file = os.path.join(self.basedir, self.SUICIDE_PREVENTION_HOTLINE_FILE) @@ -115,6 +117,8 @@ class Client(node.Node, Referenceable): self.log("connected to vdrive server") d = vdrive_server.callRemote("get_public_root_furl") d.addCallback(self._got_vdrive_root_furl, vdrive_server) + d.addCallback(self._create_my_vdrive) + d.addCallback(self._got_my_vdrive) def _got_vdrive_root_furl(self, vdrive_root_furl, vdrive_server): root = DirectoryNode(vdrive_root_furl, self) @@ -131,6 +135,34 @@ class Client(node.Node, Referenceable): webish = self.getServiceNamed("webish") webish.set_vdrive_root(root) + def _create_my_vdrive(self, ignored=None): + MY_VDRIVE_FURL_FILE = os.path.join(self.basedir, + self.MY_VDRIVE_FURL_FILE) + try: + f = open(MY_VDRIVE_FURL_FILE, "r") + my_vdrive_furl = f.read().strip() + f.close() + return defer.succeed(DirectoryNode(my_vdrive_furl, self)) + except EnvironmentError: + d = self._vdrive_server.callRemote("create_directory") + def _got_directory(dirnode): + f = open(MY_VDRIVE_FURL_FILE, "w") + f.write(dirnode.furl + "\n") + f.close() + dirnode._set_client(self) + return dirnode + d.addCallback(_got_directory) + return d + + def _got_my_vdrive(self, my_vdrive): + assert isinstance(my_vdrive, DirectoryNode), my_vdrive + self._my_vdrive = my_vdrive + + if "webish" in self.namedServices: + webish = self.getServiceNamed("webish") + webish.set_my_vdrive_root(my_vdrive) + + def remote_get_versions(self): return str(allmydata.__version__), str(self.OLDEST_SUPPORTED_VERSION) diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index 16f5cda0..b5cd72d9 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -10,7 +10,8 @@

Welcome To AllMyData! (tahoe2)

-
+
+

Grid Status

diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index e40e15bd..9671ef6b 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -63,12 +63,20 @@ class Welcome(rend.Page): ctx.fillSlots("peerid", nodeid_a) return ctx.tag - def render_vdrive(self, ctx, data): - if IClient(ctx).connected_to_vdrive(): + def render_global_vdrive(self, ctx, data): + if self.has_global_vdrive: return T.p["To view the global shared filestore, ", - T.a(href="../vdrive")["Click Here!"], + T.a(href="../global_vdrive")["Click Here!"], + ] + return T.p["vdrive.furl not specified (or vdrive server not " + "responding), no vdrive available."] + + def render_my_vdrive(self, ctx, data): + if self.has_my_vdrive: + return T.p["To view your personal private non-shared filestore, ", + T.a(href="../my_vdrive")["Click Here!"], ] - return T.p["vdrive.furl not specified, no vdrive available."] + return T.p["personal vdrive not available."] # this is a form where users can download files by URI @@ -351,6 +359,8 @@ class WebishServer(service.MultiService): def __init__(self, webport): service.MultiService.__init__(self) self.root = Root() + self.root.child_welcome.has_global_vdrive = False + self.root.child_welcome.has_my_vdrive = False placeholder = static.Data("sorry, still initializing", "text/plain") self.root.putChild("vdrive", placeholder) self.root.putChild("", url.here.child("welcome"))#Welcome()) @@ -372,8 +382,13 @@ class WebishServer(service.MultiService): #self.site._client = self.parent def set_vdrive_root(self, root): - self.root.putChild("vdrive", Directory(root, "/")) + self.root.putChild("global_vdrive", Directory(root, "/")) + self.root.child_welcome.has_global_vdrive = True # I tried doing it this way and for some reason it didn't seem to work #print "REMEMBERING", self.site, dl, IDownloader #self.site.remember(dl, IDownloader) + def set_my_vdrive_root(self, my_vdrive): + self.root.putChild("my_vdrive", Directory(my_vdrive, "~")) + self.root.child_welcome.has_my_vdrive = True +