Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreferencesHelper unable to synchronize mutations on nested containers #194

Open
kitchoi opened this issue Nov 6, 2020 · 1 comment
Open

Comments

@kitchoi
Copy link
Contributor

kitchoi commented Nov 6, 2020

Similar to #129, currently mutations on nested containers for traits defined on a subclass of PreferencesHelper cannot be synchronized with the Preferences.

e.g.

from apptools.preferences.api import Preferences, PreferencesHelper
from traits.api import Int, List, Str


class MyPreferencesHelper(PreferencesHelper):
    preferences_path = Str('my_section')
    list_of_list_of_str = List(List(Str))

pref = Preferences(filename="tmp.ini")
helper = MyPreferencesHelper(preferences=pref, list_of_list_of_str=[["1"]])
helper.list_of_list_of_str[0].append("9")
pref.save()

The saved preferences would be:

[my_section]
list_of_list_of_str = [['1']]

Expected:

[my_section]
list_of_list_of_str = [['1', '9']]
@kitchoi
Copy link
Contributor Author

kitchoi commented Dec 7, 2020

Note that the example above with nested List of List did happen to work prior to Traits 6.1. More specifically, before this fix: enthought/traits#1018
But if it was a list of dict or a list of set, it still wouldn't work.

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

No branches or pull requests

1 participant