]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: add when_done= to POST /uri?t=upload . I did not add a 'recent uploads' secti...
authorBrian Warner <warner@allmydata.com>
Wed, 6 Feb 2008 09:38:16 +0000 (02:38 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 6 Feb 2008 09:38:16 +0000 (02:38 -0700)
docs/webapi.txt
src/allmydata/test/test_web.py
src/allmydata/webish.py

index 6b97019b6f4911c886fb63e109560f7faac27e9c..e4685e3bed9e5a74eb73df6349ce5703aa3c29b2 100644 (file)
@@ -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
    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
 
 
   POST http://localhost:8123/uri?t=upload&mutable=true
 
index c6ba8d48a90560874ba4b6194888198987879fea..eb7fb809da9df71c0fabc4a3e24976bd2ff17b98 100644 (file)
@@ -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, "/")
         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
         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",
 
     def test_POST_upload_no_link_mutable(self):
         d = self.POST("/uri", t="upload", mutable="true",
index ae47138f13cd4ac0349a4ea4ca7da56b45b59218..8704f6dde9f4c531441f6102b67ff11135b6e908 100644 (file)
@@ -1256,6 +1256,17 @@ class UnlinkedPOSTCHKUploader(rend.Page):
         d = client.upload(uploadable)
         d.addBoth(self._done.fire)
 
         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()
 
     def upload_results(self):
         return self._done.when_fired()