webish: add option to export/import shared directories (always read-write)

This commit is contained in:
Brian Warner 2007-06-15 02:31:23 -07:00
parent 53da82ec04
commit 2066e8ddfc
2 changed files with 21 additions and 0 deletions

View File

@ -13,6 +13,9 @@
<div><a href=".">Refresh this view</a></div>
<div><a href="..">Parent Directory</a></div>
<div>To share this directory, paste the following FURL string into an
"Add Shared Directory" box:
<pre class="overflow" n:render="string" n:data="share_url" /></div>
<table n:render="sequence" n:data="children" border="1">
<tr n:pattern="header">

View File

@ -136,6 +136,9 @@ class Directory(rend.Page):
def render_header(self, ctx, data):
return "Directory of '%s':" % self._dirname
def data_share_url(self, ctx, data):
return self._dirnode.furl
def data_children(self, ctx, data):
d = self._dirnode.list()
return d
@ -265,6 +268,21 @@ class Directory(rend.Page):
d.addCallback(_done)
return d
def bind_mount(self, ctx):
namearg = annotate.Argument("name",
annotate.String("Name to place incoming directory: "))
furlarg = annotate.Argument("furl",
annotate.String("FURL of Shared Directory"))
meth = annotate.Method(arguments=[namearg, furlarg],
label="Add Shared Directory")
return annotate.MethodBinding("mount", meth,
action="Mount Shared Directory")
def mount(self, name, furl):
d = self._dirnode.attach_shared_directory(name, furl)
d.addCallback(lambda done: url.here.child(name))
return d
def child__delete(self, ctx):
# perform the delete, then redirect back to the directory page
args = inevow.IRequest(ctx).args