Enable extensions to provide a default settings dictionary
Review Request #2907 — Created Feb. 20, 2012 and submitted
When an extension is loaded for the first time it is initialized with an empty settings dictionary. All extension authors must either initialize the settings dictionary and save it, or check at use if the setting exists. This modification allows an extension author to specify a default settings dictionary, which will be used if a key is not present in extension.settings. Instead of copying all defaults, I only reference them when a missing key is accessed. Another option would be to initialize the settings when the extension is loaded. Feel free to suggest other ideas.
Tested in local dev with dummy extensions. Ran djblets unit tests.
Description | From | Last Updated |
---|---|---|
This chunk of code could probably be refactored. Usually you don't want to explicitly return a boolean, but rather do … |
ME medanat | |
I'd prefer "" instead of []. To make it more readable code-wise with "", you can use '' for the … |
chipx86 | |
Each dict key should be on its own line: "" % { 'key': key, 'ext': self.extension.id, } |
chipx86 | |
If you make the default for default_settings be {} instead, this can just be: return key in self.extension.default_settings You can … |
chipx86 |