From: david-sarah Date: Sun, 24 Jan 2010 03:00:20 +0000 (-0800) Subject: Patch to accept t=set-children as well as t=set_children X-Git-Tag: trac-4200~15 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/%5B%5E?a=commitdiff_plain;h=5c5a6fe610413959c55f342083f80d91dfa4d087;p=tahoe-lafs%2Ftahoe-lafs.git Patch to accept t=set-children as well as t=set_children --- diff --git a/docs/frontends/webapi.txt b/docs/frontends/webapi.txt index e955933b..a16ccc5c 100644 --- a/docs/frontends/webapi.txt +++ b/docs/frontends/webapi.txt @@ -666,6 +666,7 @@ PUT /uri/$DIRCAP/[SUBDIRS../]CHILDNAME?t=uri === Adding multiple files or directories to a parent directory at once === POST /uri/$DIRCAP/[SUBDIRS..]?t=set_children +POST /uri/$DIRCAP/[SUBDIRS..]?t=set-children (Tahoe >= v1.6) This command adds multiple children to a directory in a single operation. It reads the request body and interprets it as a JSON-encoded description @@ -694,6 +695,11 @@ POST /uri/$DIRCAP/[SUBDIRS..]?t=set_children currently placed here are "linkcrtime" and "linkmotime". For details, see the section above entitled "Get Information About A File Or Directory (as JSON)", in the "About the metadata" subsection. + + Note that this command was introduced with the name "set_children", which + uses an underscore rather than a hyphen as other multi-word command names + do. The variant with a hyphen is now accepted, but clients that desire + backward compatibility should continue to use "set_children". === Deleting a File or Directory === diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index d4f4bb53..1829f093 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -2236,7 +2236,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase): self.POST, self.public_url + "/foo", t="BOGUS") return d - def test_POST_set_children(self): + def test_POST_set_children(self, command_name="set_children"): contents9, n9, newuri9 = self.makefile(9) contents10, n10, newuri10 = self.makefile(10) contents11, n11, newuri11 = self.makefile(11) @@ -2265,7 +2265,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase): } ] }""" % (newuri9, newuri10, newuri11) - url = self.webish_url + self.public_url + "/foo" + "?t=set_children" + url = self.webish_url + self.public_url + "/foo" + "?t=" + command_name d = client.getPage(url, method="POST", postdata=reqbody) def _then(res): @@ -2277,6 +2277,9 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase): d.addErrback(self.dump_error) return d + def test_POST_set_children_with_hyphen(self): + return self.test_POST_set_children(command_name="set-children") + def test_POST_put_uri(self): contents, n, newuri = self.makefile(8) d = self.POST(self.public_url + "/foo", t="uri", name="new.txt", uri=newuri) diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index fe5b0462..299421f1 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -220,7 +220,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin): d = self._POST_start_deep_stats(ctx) elif t == "stream-manifest": d = self._POST_stream_manifest(ctx) - elif t == "set_children": + elif t == "set_children" or t == "set-children": d = self._POST_set_children(req) else: raise WebError("POST to a directory with bad t=%s" % t)