From: Zooko O'Whielacronx Date: Wed, 16 May 2007 15:40:19 +0000 (-0700) Subject: enable private upload, in which the file is inserted at the grid layer but not at... X-Git-Tag: allmydata-tahoe-0.3.0~79 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/provisioning?a=commitdiff_plain;h=9b70d17d4bc4d3444e4e905c2e6bbcce0e92949d;p=tahoe-lafs%2Ftahoe-lafs.git enable private upload, in which the file is inserted at the grid layer but not at the vdrive layer This patch is actually by Faried Nawaz, as per ticket #33: http://allmydata.org/trac/tahoe/ticket/33 --- diff --git a/src/allmydata/web/directory.xhtml b/src/allmydata/web/directory.xhtml index 98fe00e7..6ee528f3 100644 --- a/src/allmydata/web/directory.xhtml +++ b/src/allmydata/web/directory.xhtml @@ -35,7 +35,7 @@
- +
diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index b8dce062..5275b0de 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -155,6 +155,13 @@ class Directory(rend.Page): def render_forms(self, ctx, data): return webform.renderForms() + def render_results(self, ctx, data): + req = inevow.IRequest(ctx) + if "results" in req.args: + return req.args["results"] + else: + return "" + def bind_upload(self, ctx): """upload1""" # Note: this comment is no longer accurate, as it reflects the older @@ -173,20 +180,31 @@ class Directory(rend.Page): requiredFailMessage="Do iT!") contentsarg = annotate.Argument("contents", up) + privateUpload = annotate.Radio(label="Private?", choices=["Yes"]) + privatearg = annotate.Argument("privateupload", privateUpload) + ctxarg = annotate.Argument("ctx", annotate.Context()) - meth = annotate.Method(arguments=[contentsarg, ctxarg], + meth = annotate.Method(arguments=[contentsarg, privatearg, ctxarg], label="Upload File to this directory") return annotate.MethodBinding("upload", meth, action="Upload") - def upload(self, contents, ctx): + def uploadprivate(self, filename, uri): + message = "webish upload complete, filename %s %s" % (filename, uri) + log.msg(message) + return url.here.add("filename", filename).add("results", message) + + def upload(self, contents, privateupload, ctx): # contents is a cgi.FieldStorage instance log.msg("starting webish upload") uploader = get_uploader_service(ctx) d = uploader.upload(upload.Data(contents.value)) name = contents.filename - d.addCallback(lambda vid: - self._dirnode.callRemote("add_file", name, vid)) + if privateupload: + d.addCallback(lambda vid: self.uploadprivate(name, vid)) + else: + d.addCallback(lambda vid: + self._dirnode.callRemote("add_file", name, vid)) def _done(res): log.msg("webish upload complete") return res