Merge lp:~facundo/magicicada-server/better-settings-local into lp:magicicada-server
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 84 |
Merged at revision: | 83 |
Proposed branch: | lp:~facundo/magicicada-server/better-settings-local |
Merge into: | lp:magicicada-server |
Diff against target: |
42 lines (+6/-6) 1 file modified
magicicada/settings/__init__.py (+6/-6) |
To merge this branch: | bzr merge lp:~facundo/magicicada-server/better-settings-local |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart | Approve | ||
Review via email: mp+323667@code.launchpad.net |
Commit message
Better handling of broken local settings, and allow changing values.
Description of the change
Better handling of broken local settings, and allow changing values.
IOW, I converted the simple "import local and pass if broken" to the following sequence:
- try to import * from local settings
- if broken, inform how!
- if all went ok, also try to import a pre-defined function
- if the function is not there, just pass (it's ok, this new function is optional)
- if the function is there, execute it.
The idea of this new function is to allow the local settings to *modify* a generic settings (not only overwrite it). For an example of how this would be useful, check what I'm doing in my local settings: http://
Hum, I really really don't like the fix_settings function. But if you feel very strong about it, could you please at least call it "override_ settings" ?
For needs like this, what I would propose is using a more "traditional" approach with env vars. Something like:
* in magicicada/ settings/ __init_ _.py:
173 LOGGING = { 'MAGICICADA_ LOG_LEVEL' , 'INFO'),
...
204 'loggers': {
205 'django': {
206 'handlers': ['file'],
207 'level': os.getenv(
208 'propagate': True,
209 },
...
221 }
And then just export the env var to the value you desire, or execute the server with:
MAGICICADA_ LOG_LEVEL= DEBUG make start
Or alternatively, we could define a "debug" policy, a little big more "global", such as this:
LOG_LEVEL = 'INFO' if bool(os. getenv( 'MAGICICADA_ DEBUG', None)) else 'DEBUG'
173 LOGGING = {
...
204 'loggers': {
205 'django': {
206 'handlers': ['file'],
207 'level': LOG_LEVEL,
208 'propagate': True,
209 },
...
221 }
What do you think?