t=set_children uses an underscore, when all other webapi commands use hyphens #927

Closed
opened 2010-01-24 01:54:13 +00:00 by davidsarah · 7 comments
davidsarah commented 2010-01-24 01:54:13 +00:00
Owner

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.

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.
tahoe-lafs added the
code-frontend-web
major
defect
1.5.0
labels 2010-01-24 01:54:13 +00:00
tahoe-lafs added this to the 1.6.0 milestone 2010-01-24 01:54:13 +00:00
tahoe-lafs changed title 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 2010-01-24 01:54:58 +00:00
davidsarah commented 2010-01-24 03:15:52 +00:00
Author
Owner

Attachment accept-set-children-hyphen-darcspatch.txt (40902 bytes) added

Patch to accept t=set-children as well as t=set_children

**Attachment** accept-set-children-hyphen-darcspatch.txt (40902 bytes) added Patch to accept t=set-children as well as t=set_children
zooko commented 2010-01-26 05:05:59 +00:00
Author
Owner

This looks good, but there are other uses of set_children in source:docs/frontends/webapi.txt, in [tahoe cp]source:src/allmydata/scripts/tahoe_cp.py 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)

This looks good, but there are other uses of `set_children` in source:docs/frontends/webapi.txt, in [tahoe cp]source:src/allmydata/scripts/tahoe_cp.py 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)
davidsarah commented 2010-01-26 06:31:19 +00:00
Author
Owner

Replying to zooko:

This looks good, but there are other uses of set_children in source:docs/frontends/webapi.txt, in [tahoe cp]source:src/allmydata/scripts/tahoe_cp.py 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.

Replying to [zooko](/tahoe-lafs/trac-2024-07-25/issues/927#issuecomment-116699): > This looks good, but there are other uses of `set_children` in source:docs/frontends/webapi.txt, in [tahoe cp]source:src/allmydata/scripts/tahoe_cp.py 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.
davidsarah commented 2010-01-26 06:36:12 +00:00
Author
Owner

Oops, the instance of set_children in source:misc/booglegrid.tac did need to change. Wouldn't want to break that :-)

Oops, the instance of `set_children` in source:misc/booglegrid.tac did need to change. Wouldn't want to break that :-)
davidsarah commented 2010-01-26 06:41:40 +00:00
Author
Owner

Attachment boodlegrid-patch.txt (39043 bytes) added

Fix boodlegrid to play sound on both set_children and set-children (vital functionality nearly broken!)

**Attachment** boodlegrid-patch.txt (39043 bytes) added Fix boodlegrid to play sound on both set_children and set-children (vital functionality nearly broken!)
zooko commented 2010-01-26 15:10:25 +00:00
Author
Owner

applied vital fix as changeset:584c0ed487d7e4b7

applied vital fix as changeset:584c0ed487d7e4b7
zooko commented 2010-01-26 15:37:09 +00:00
Author
Owner

Oh yeah and the forward-compatibility, wapi improvement patch as changeset:5c5a6fe610413959.

Oh yeah and the forward-compatibility, wapi improvement patch as changeset:5c5a6fe610413959.
tahoe-lafs added the
fixed
label 2010-01-26 15:37:54 +00:00
zooko closed this issue 2010-01-26 15:37:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#927
No description provided.