Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #605 (closed enhancement: wontfix)

Opened 13 years ago

Last modified 10 years ago

Defaults for dicts

Reported by: simon Owned by: anonymous
Priority: normal Milestone: 1.x
Component: TG Widgets Version:
Severity: normal Keywords: default, nested, dict
Cc: michele, alberto

Description

Michele in #577:

Anyway I think we should do something to manage default arguments when they are dict, for example ATM you can't provide the default only for one field because the whole input dict is used, the right solution it to just update the default dict with the input value one and do it recursively because we could have nested dicts, this should be easy, we just need to walk every dict key if it's a dict and update it (I do something similar in the update_errors_dict_from_parent method that's inside the patch).

Or we could have defaults in form of:

{"foo.baz.bar":42, "foo.buz":13, "fu.ber":69}

+ faster/simpler to populate

+ easier to type

+ easier to read

+ less verbose

  • doesn't work with dict() constructor (things like that could lead to nasty bugs)

Change History

comment:1 Changed 13 years ago by alberto

Hi Simon,

While its true that it's easier to populate, easier to read and less verbose, i think it will be less intuitive because the method parmeters are expected as nested dicts, not as a coded flat dicts which then get decoded.

It will also lock us to the dotted path notation (I'm not saying there's anything wrong with it) which is something internal to the nested varibles "codec" and should be transparent to the user (IMO).

The point is that only "python" structures should be seen at the python/controller side (IMO).

The speed gain I don't see it would make a difference either as this default dict should be parsed anyhow by the NestedVariables? decoder before handing the params to the method's body.

Regards, Alberto

comment:2 Changed 13 years ago by michele

I agree with Alberto, the dotted notation is not pythonic and an implementation detail we shouldn't expose on the controller side, it will also need another translation with NestedVariables? I guess.

comment:3 Changed 13 years ago by simon

comment:4 Changed 13 years ago by godoy

Any news on that?

comment:5 Changed 13 years ago by khorn

  • Milestone 0.9 deleted

milestone passed, removing milestone

Has anyone worked on this lately?

comment:6 Changed 13 years ago by jorge.vargas

  • Milestone set to __future__

comment:7 Changed 10 years ago by jorge.vargas

  • Milestone changed from __future__ to 1.x

comment:8 Changed 10 years ago by Chris Arndt

  • Status changed from new to closed
  • Resolution set to wontfix

Cruft ticket. Nobody seems to have missed this feature (whatever it was exactly, I'm not really able to tell from the description, what was proposed), so closing this as "wontfix".

Note: See TracTickets for help on using tickets.