#927 closed defect (fixed)
t=set_children uses an underscore, when all other webapi commands use hyphens
Reported by: | davidsarah | Owned by: | davidsarah |
---|---|---|---|
Priority: | major | Milestone: | 1.6.0 |
Component: | code-frontend-web | Version: | 1.5.0 |
Keywords: | usability forward-compatibility backward-compatibility easy news-done | Cc: | |
Launchpad Bug: |
Description
That is how it is documented in webapi.txt, but it still took me half an hour of scratching my head wondering why I was getting the response "POST to a directory with bad t=set-children".
We should accept both the underscore and the hyphen in 1.6. The patch to do that is trivial; change t == "set_children" at source:src/allmydata/web/directory.py?rev=4166#L223 to {{t == "set_children" or t == "set-children"}}}, add a unit test in test_web.py, and update webapi.txt.
Attachments (2)
Change History (11)
comment:1 Changed at 2010-01-24T01:54:58Z by davidsarah
- Owner set to davidsarah
- Status changed from new to assigned
- Summary changed from {{{t=set_children}}} uses an underscore, when all other webapi commands use hyphens to t=set_children uses an underscore, when all other webapi commands use hyphens
Changed at 2010-01-24T03:15:52Z by davidsarah
comment:2 Changed at 2010-01-24T03:16:44Z by davidsarah
- Keywords review-needed added
comment:3 follow-up: ↓ 4 Changed at 2010-01-26T05:05:59Z by zooko
- Keywords review-needed removed
This looks good, but there are other uses of set_children in docs/frontends/webapi.txt, in tahoe cp and possibly more. Could you change those to set-children as well?
$ shopt -s extglob $ grep -r "[^A-Za-z-_]set_children[^A-Za-z-_]" !(_darcs) NEWS:using separate "t=mkdir" and "t=set_children" operations (it uses one NEWS:The t=set_children operation is now documented in docs/frontends/webapi.txt . docs/frontends/webapi.txt: efficient than doing separate mkdir and set_children operations). If the docs/frontends/webapi.txt: "set_children" API (described below) which you can use to overwrite the docs/frontends/webapi.txt: into the Tahoe filesystem. As of Tahoe v1.4.0, the set_children API cannot docs/frontends/webapi.txt: use it as the input to "POST /uri/$DIRCAP2?t=set_children" to make DIR2 docs/frontends/webapi.txt: When the set_children request contains a child name that already exists in docs/frontends/webapi.txt: behavior. If you use "?t=set_children&overwrite=false", then an attempt to docs/frontends/webapi.txt: Note that this command was introduced with the name "set_children", which docs/frontends/webapi.txt: backward compatibility should continue to use "set_children". misc/boodlegrid.tac: and "t=set_children" in m.get("uri", "")): src/allmydata/dirnode.py: def set_children(self, entries, overwrite=True): src/allmydata/interfaces.py: def set_children(entries, overwrite=True): src/allmydata/scripts/consolidate.py: # build up contents to pass to mkdir() (which uses t=set_children) src/allmydata/scripts/consolidate.py: url = self.nodeurl + "uri/%s?t=set_children" % urllib.quote(dircap) src/allmydata/scripts/consolidate.py: raiseHTTPError("error during set_children", resp) src/allmydata/scripts/tahoe_cp.py: def set_children(self): src/allmydata/scripts/tahoe_cp.py: def set_children(self): src/allmydata/scripts/tahoe_cp.py: + "?t=set_children") src/allmydata/scripts/tahoe_cp.py: # it just so happens that ?t=set_children will accept both file src/allmydata/scripts/tahoe_cp.py: # read-caps, then do a set_children to the target directory. src/allmydata/scripts/tahoe_cp.py: target.set_children() src/allmydata/scripts/tahoe_cp.py: # data, and stash the new filecap for a later set_children call. src/allmydata/scripts/tahoe_cp.py: # data, and stash the new filecap for a later set_children call. src/allmydata/test/test_deepcheck.py: return subdir_node.set_children(kids) src/allmydata/test/test_dirnode.py: # metadata through set_children() src/allmydata/test/test_dirnode.py: n.set_children({ src/allmydata/test/test_dirnode.py: n.set_children, src/allmydata/test/test_web.py: def test_POST_set_children(self, command_name="set_children"): src/allmydata/web/directory.py: elif t == "set_children" or t == "set-children": src/allmydata/web/directory.py: d = self.node.set_children(cs, replace)
comment:4 in reply to: ↑ 3 Changed at 2010-01-26T06:31:19Z by davidsarah
Replying to zooko:
This looks good, but there are other uses of set_children in docs/frontends/webapi.txt, in tahoe cp and possibly more. Could you change those to set-children as well?
I intentionally didn't do that, because I think that the uses in code should continue to use set_children for the time being in case they are connecting to an older webapi server. I also didn't want to change other uses in webapi.txt outside the section that explicitly gives the backward compatibility notice. Many of the cases in your grep are also method names, not the webapi parameter.
comment:5 Changed at 2010-01-26T06:36:12Z by davidsarah
Oops, the instance of set_children in source:misc/booglegrid.tac did need to change. Wouldn't want to break that :-)
Changed at 2010-01-26T06:41:40Z by davidsarah
Fix boodlegrid to play sound on both set_children and set-children (vital functionality nearly broken!)
comment:6 Changed at 2010-01-26T15:10:25Z by zooko
applied vital fix as 584c0ed487d7e4b7
comment:7 Changed at 2010-01-26T15:37:09Z by zooko
Oh yeah and the forward-compatibility, wapi improvement patch as 5c5a6fe610413959.
comment:8 Changed at 2010-01-26T15:37:54Z by zooko
- Resolution set to fixed
- Status changed from assigned to closed
comment:9 Changed at 2010-02-02T06:11:35Z by davidsarah
- Keywords news-done added
Patch to accept t=set-children as well as t=set_children