Skip to content

Should WidgetBunch.__getattr__ work on key instead of id? #98

@amol-

Description

@amol-

Currently WidgetBunch.getattr is provided as a quick way to access children for which the identifier is known.

This works pretty well, but it might actually be the case where the id of a widget changes depending on the context where it is rendered. This has the side effect of forcing the developer to implement logic to cope with variables id when using w.children.child_name

While the id might change due to DOM requirements (avoiding collisions) or javascript requirements, the widget key will probably stay the same due to the controller code/layer being usually less variable than the presentation layer.

I know that most of this can be avoided by using automatic ids and referring only to classes for all the JS, semantic meaning and styling of the widgets. But that means that the user should stick to some rules that are not officially enforced by tw2 (I can freely change the id) and are not always enforceable.

Implementatioon should be quick, I can work out a pull request if everyone is fine with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions