]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: look for when_done= in POST fields as well as queryargs. Closes #101.
authorBrian Warner <warner@allmydata.com>
Tue, 14 Aug 2007 00:45:02 +0000 (17:45 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 14 Aug 2007 00:45:02 +0000 (17:45 -0700)
We need to look in the fields because that's how we build the mkdir/upload
forms. Without this, uploading or creating directories would leave us on a
page that had just a URI, instead of something actually useful to a human.

src/allmydata/test/test_web.py
src/allmydata/webish.py

index add61e56bd61828f8a376552081e57b8861a1307..d489a2adfd55f8018e307b5f418a3539af106bb5 100644 (file)
@@ -882,6 +882,18 @@ class Web(WebMixin, unittest.TestCase):
         d.addCallback(_check)
         return d
 
+    def test_POST_upload_whendone(self):
+        d = self.POST("/vdrive/global/foo", t="upload", when_done="/THERE",
+                      file=("new.txt", self.NEWFILE_CONTENTS))
+        d.addBoth(self.shouldRedirect, "/THERE")
+        def _check(res):
+            self.failUnless("new.txt" in self._foo_node.children)
+            new_uri = self._foo_node.children["new.txt"]
+            new_contents = self.files[new_uri]
+            self.failUnlessEqual(new_contents, self.NEWFILE_CONTENTS)
+        d.addCallback(_check)
+        return d
+
     def test_POST_upload_named(self):
         d = self.POST("/vdrive/global/foo", t="upload",
                       name="new.txt", file=self.NEWFILE_CONTENTS)
@@ -921,7 +933,19 @@ class Web(WebMixin, unittest.TestCase):
         d.addCallback(_check)
         return d
 
-    def test_POST_mkdir_whendone(self):
+    def test_POST_mkdir_whendone_field(self):
+        d = self.POST("/vdrive/global/foo",
+                      t="mkdir", name="newdir", when_done="/THERE")
+        d.addBoth(self.shouldRedirect, "/THERE")
+        def _check(res):
+            self.failUnless("newdir" in self._foo_node.children)
+            newdir_uri = self._foo_node.children["newdir"]
+            newdir_node = self.nodes[newdir_uri]
+            self.failIf(newdir_node.children)
+        d.addCallback(_check)
+        return d
+
+    def test_POST_mkdir_whendone_queryarg(self):
         d = self.POST("/vdrive/global/foo?when_done=/THERE",
                       t="mkdir", name="newdir")
         d.addBoth(self.shouldRedirect, "/THERE")
index d00884c265f6e46379f2cab92029f47619f52c1b..878c7fbb204da3ec42ce3cef5bfb54279fe3cfd3 100644 (file)
@@ -573,6 +573,8 @@ class POSTHandler(rend.Page):
         when_done = None
         if "when_done" in req.args:
             when_done = req.args["when_done"][0]
+        if "when_done" in req.fields:
+            when_done = req.fields["when_done"].value
 
         if t == "mkdir":
             if not name: