Skip to content

When should settings get saved? #111

@rwb27

Description

@rwb27

Currently, settings ought to be saved any time anything changes in the ThingSettings dictionary. However, they are not (#108) - currently they only get saved when they are explicitly synced.

A sensible way forward might be a shallow auto-saving structure: if any item in ThingSettings is set, or if it's explicitly requested, we update settings.json. This has a few advantages:

  • It is rather easier to make it work, and test that it works
  • We don't have to wrap everything in home-made reactive types
  • It's clear when settings are saved

The major drawback (and I think we should go ahead anyway) is that most Python objects are mutable, so it's possible to change the settings without that change being detected. For example, if a dictionary is stored in settings, it can be changed without ThingSettings re-syncing it to disk:

self.thing_settings["settingname"]["keyname"] = "value"

This is only reading self.thing_settings["settingname"] so nothing is triggered in thing_settings. That's not a unique issue to us though - I think it is reasonable just to be clear that the line above would require a call to thing_settings.sync() or similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions