Skip to content

Fields are identified only by dotted strings; no field handle to write, reset or subscribe through #46

Open

Description

@trissim

What happens at 1fcdf12: every field is named by a dotted string: update_parameter("ui.footer", v), reset_parameter, get_resolved_value, the sets passed to on_state_changed/on_resolved_changed, dirty_fields. state.fields (FieldProxy, object_state.py:49-118) reads by attribute but returns Any, cannot write, and cannot be subscribed to. Subscription is per state, so each subscriber filters the changed-path set by comparing strings.

Nothing checks a path until it runs, and (see the issue on swallowed errors) a wrong one is then a silent no-op.

Wanted: a field handle object obtained from the declaration (for example state.field(UiSettings, "footer") validated once, or attribute access on a typed path builder) that carries read, write, reset, "is dirty" and "call me when this field changes", so consumers hold a handle and never spell a path.

Workaround in Toad now: toad.forms.FieldPath builds and validates the dotted path from the dataclass declarations once, and views subscribe through it.

Acceptance: a consumer can write, reset and subscribe to one field without a string literal for its path, and a handle for a field that does not exist fails where it is created.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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