From: Brian Warner Date: Wed, 6 Feb 2008 09:38:16 +0000 (-0700) Subject: webish: add when_done= to POST /uri?t=upload . I did not add a 'recent uploads' secti... X-Git-Tag: allmydata-tahoe-0.8.0~129 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20//%22%22?a=commitdiff_plain;h=6e0d3059a3e028639f6460f10cbac0c04923f471;p=tahoe-lafs%2Ftahoe-lafs.git webish: add when_done= to POST /uri?t=upload . I did not add a 'recent uploads' section to the welcome page, but I think the new upload-results page provides the desired data --- diff --git a/docs/webapi.txt b/docs/webapi.txt index 6b97019b..e4685e3b 100644 --- a/docs/webapi.txt +++ b/docs/webapi.txt @@ -179,7 +179,9 @@ f. uploading a file This action also uploads a file without attaching it to a virtual drive directory, but can be used from an HTML form. The response is an HTML page that describes the results of the upload, including the resulting URI (but - also including information about which peers were used, etc). + also including information about which peers were used, etc). If a + when_done=URL argument is provided, the reponse is a redirect to the given + URL instead of the upload-results page. POST http://localhost:8123/uri?t=upload&mutable=true diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index c6ba8d48..eb7fb809 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -1011,11 +1011,7 @@ class Web(WebMixin, unittest.TestCase): d = self.POST("/uri", t="upload", when_done="/", file=("new.txt", self.NEWFILE_CONTENTS)) d.addBoth(self.shouldRedirect, "/") - # XXX Test that resulting welcome page has a "most recent - # upload", the URI of which points to the file contents that - # you just uploaded. return d - test_POST_upload_no_link_whendone.todo = "Not yet implemented." def test_POST_upload_no_link_mutable(self): d = self.POST("/uri", t="upload", mutable="true", diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index ae47138f..8704f6dd 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -1256,6 +1256,17 @@ class UnlinkedPOSTCHKUploader(rend.Page): d = client.upload(uploadable) d.addBoth(self._done.fire) + def renderHTTP(self, ctx): + req = inevow.IRequest(ctx) + when_done = get_arg(req, "when_done", None) + if when_done: + # if when_done= is provided, return a redirect instead of our + # usual upload-results page + d = self._done.when_fired() + d.addCallback(lambda res: url.URL.fromString(when_done)) + return d + return rend.Page.renderHTTP(self, ctx) + def upload_results(self): return self._done.when_fired()