From: Brian Warner Date: Mon, 4 Dec 2006 19:03:29 +0000 (-0700) Subject: add 'make directory' button to webish X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~459 X-Git-Url: https://git.rkrishnan.org/webform_css?a=commitdiff_plain;h=b8ad3da5e5bf69109dd53a95f483e9abbc6ebcf9;p=tahoe-lafs%2Ftahoe-lafs.git add 'make directory' button to webish --- diff --git a/allmydata/webish.py b/allmydata/webish.py index c4f18f69..5c63b05a 100644 --- a/allmydata/webish.py +++ b/allmydata/webish.py @@ -37,16 +37,31 @@ class Welcome(rend.Page): addSlash = True docFactory = getxmlfile("welcome.xhtml") -class IUpload(annotate.TypedInterface): +class IDirectoryEditor(annotate.TypedInterface): def upload(contents=annotate.FileUpload(label="Choose a file to upload: ", required=True, requiredFailMessage="Do iT!"), ctx=annotate.Context(), ): + # Each method gets a box. The string in the autocallable(action=) + # argument is put on the border of the box, as well as in the submit + # button. The top-most contents of the box are the method's + # docstring, if any. Each row contains a string for the argument + # followed by the argument's input box. If you do not provide an + # action= argument to autocallable, the method name is capitalized + # and used instead. #"""Upload a file""" pass upload = annotate.autocallable(upload, action="Upload file") + def mkdir(name=annotate.String("Create a new directory named: ", + required=True, + requiredFailMessage="You must choose a directory"), + ): + #"""Create a directory.""" + pass + mkdir = annotate.autocallable(mkdir, action="Make directory") + class Directory(rend.Page): addSlash = True docFactory = getxmlfile("directory.xhtml") @@ -104,7 +119,7 @@ class Directory(rend.Page): # this tells formless about what functions can be invoked, giving it # enough information to construct form contents - implements(IUpload) + implements(IDirectoryEditor) child_webform_css = webform.defaultCSS def render_forms(self, ctx, data): @@ -127,6 +142,15 @@ class Directory(rend.Page): return url.here.add("results", "upload of '%s' complete!" % contents.filename) + def mkdir(self, name): + log.msg("making new webish directory") + d = self._dirnode.callRemote("add_directory", name) + def _done(res): + log.msg("webish mkdir complete") + return res + d.addCallback(_done) + return d + class WebDownloadTarget: implements(IDownloadTarget) def __init__(self, req):