From: Brian Warner Date: Tue, 14 Aug 2007 00:45:02 +0000 (-0700) Subject: webish: look for when_done= in POST fields as well as queryargs. Closes #101. X-Git-Url: https://git.rkrishnan.org/class-simplejson.JSONEncoder-index.html?a=commitdiff_plain;h=179d5462c0d95ea8539e2694f8a1ac6eb6982b12;p=tahoe-lafs%2Ftahoe-lafs.git webish: look for when_done= in POST fields as well as queryargs. Closes #101. 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. --- diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index add61e56..d489a2ad 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -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") diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index d00884c2..878c7fbb 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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: