Conversation
Massively prototypey
This changes behaviour - now if ALLOWED_HOSTS is not set in the environment, you get an empty list; previously you got a list containing the empty string. This is essentially a bug fix - `[]` is a much more sensible value than `['']`
(Poorly-worded, but it exists)
|
(Oh, also if you have advice on a) why that code block isn't rendering b) good tools for syntax/style checking of RST, that'd be amazing please) |
README.rst
Outdated
There was a problem hiding this comment.
I think loader should be parser in that constructor
There was a problem hiding this comment.
Yes, that would be significantly better, thanks!
README.rst
Outdated
There was a problem hiding this comment.
Do you (or could you) provide a "smart bool" option? Simply using bool on a string from os.environ always returns True unless it's empty. Took me ages to figure out why MY_ENV=False was always True in my own stuff :(
There was a problem hiding this comment.
Yeah, thanks, I need to publicise/do more about django12factor.getenv_bool!
There was a problem hiding this comment.
Perhaps throw some kind of exception or warning if people use parser=bool too, since it's almost certainly not going to do what they want. Or, in the spirit of heroku-fucking-console, just use getenv_bool if they pass in a bool.
|
I think "For example:" needs 2 colons after to get the code bock to render. Not sure though as I don't use the |
|
Heh cheers, I thought that, but it seems identical to earlier codeblocks in my rst... |
|
Possible alternative syntax: Not sure if that is nicer or not, basically just removes lots of |
|
Yeah I'm not sure how much I like the syntax, but I've not found a happier alternative - tuples make it a pain to have optional arguments; dicts might be better, but basically I've taken a leaf from Django's |
|
Fun observations: For customisable defaults you can do something like: evl = EVL(
"DATABASE_URL",
parser=dj_database_url.parse,
default=dj_database_url.parse("your://url")
)
DATABASES['default'] = evl.load_value()which is icky but I'm not sure how best to improve it |
Conflicts: README.rst
Improved DATABASE_URL parsing
|
Changes Unknown when pulling d8d7bbe on feature/custom-loader into * on master*. |
|
Is there anything I can do to move this PR, or django12factor in general, forward? I have stopped using it for now and switched to a combination of |
|
I realize this idea is somewhat radical, but do you think we could have a "just a bunch of functions" API? DEBUG = d12f_bool('DEBUG', default=True)
SECRET_KEY = d12f_string('SECRET_KEY', require=True) # raise an exception if not set.
DATABASES['default'] = d12f_database_url('DATABASE_URL', default='your://url')
LOGGING = d12f_logging()
WHATEVER = d12f_custom('MY_ENV_VAR', parser=lambda s: s.lower()) |
Very much a WIP, but to allow type coercion, setting of defaults, etc.