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

Mapping setting #94

Open
ziima opened this issue Nov 10, 2020 · 6 comments
Open

Mapping setting #94

ziima opened this issue Nov 10, 2020 · 6 comments

Comments

@ziima
Copy link
Collaborator

ziima commented Nov 10, 2020

We have a DictSetting and a NestedDictSetting, but we lack a setting which would define a dictionary with specific values, but various keys, such as CACHES and DATABASES.

I suggest a name MappingSetting, example:

class MySettings(appsettings.AppSettings):
    my_map = appsettings.MappingSetting(appsettings.StringSetting(), default=None)

MY_MAP = {
    'question': 'unknown',
    'answer': '42',
}
@stinovlas
Copy link
Collaborator

I think this is too similar to DictSetting. Why not just expand DictSetting to handle complex value types? It can already handle simple type check.

@ziima
Copy link
Collaborator Author

ziima commented Nov 10, 2020

The complex type is another Setting, which has completely different interface than just generic type.

Or do you have any particular solution in mind?

@stinovlas
Copy link
Collaborator

The interface of the inner type is different, that's true. But I think we don't have to make the appsettings API more complicated. It seems to be quite confusing to have DictSetting and MappingSetting that do basically the same thing and differ only in their values types.

@ziima
Copy link
Collaborator Author

ziima commented Nov 11, 2020

The MappingSetting is a form of a nested setting. It might be more adequate to modify NestedDictSetting instead, but it requires changes in the core anyway.

@stinovlas
Copy link
Collaborator

NestedDictSetting is different, because it restricts the key set, unlike the setting you want. On the other hand, DictSetting does not restrict the key set. DictSetting is much more similar to what you want from the API point of view (the implementation would need to change a lot, I agree).

@ziima
Copy link
Collaborator Author

ziima commented Nov 11, 2020

NestedDictSetting unlike DictSetting is designed to contain another Setting within. In my opinion that's quite close also from the API point of view.

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

No branches or pull requests

2 participants