Meta Attribute for Requiring Settings #6

merged 5 commits into from Jan 13, 2013


None yet

3 participants


This adds support for a new (optional) AppConf.Meta attribute named "required." The attribute is a list of (unprefixed) settings that must be defined. Not defining any of the settings will result in an ImproperlyConfigured exception being raised.

@jezdez jezdez commented on the diff Jun 5, 2012
@@ -63,6 +64,11 @@ Reference
For example, ``acme`` would turn into settings like
+ .. attribute:: required
jezdez Jun 5, 2012

Can you add a .. versionadded:: 0.6 directive to the block?


Actually, now that I think about it, what would you think about a different API:

from appconf import AppConf, required

class MyConf(AppConf):

    SOMETHING_AWESOME = required('truly-epic')

    OTHER_THING = required(['foo', 'bar'])

    A_INTERESTING_FLAG = required(True)

What required would basically do is to mark the default value with a boolean and that check could be done during initialization.


Honestly, I'm not a fan; mainly because I can't think of a use case where you'd want to require a value and give it a default (since a default value means the user doesn't have to set one).


Good point, forget what I said, we'll do this like you proposed. Do you think it would be sensible to also allow the arguments passed to the required option to be lower cased (to be consistent with the configure_* methods)?


Yeah, that makes sense to me. I don't think we need to change anything though since prefixed_name is already doing the job by uppering the setting name.


This pull request fails (merged f0534ae into bf14a76).


Anything holding this up that I could take care of?


Nope, sorry!

@jezdez jezdez merged commit 0fbf0ec into django-compressor:develop Jan 13, 2013

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment