Refactored Settings Defaults

I refactored how settings and their defaults are done so that the default is in exactly one place.  Also, as I was adding a setting, our check for cyclomatic complexity prohibited having the chain of if-elif for validation, so I refactored validating settings to call subfunctions.  I also added methods to get the default value of a setting and to check if a setting was using its default value (which is distinct from just having the default value).
Should I move the _camelcase function to somewhere more general?  I'm not
sure where it would go, but it seems like it is now a general utility
function.

On Thu, Sep 25, 2014 at 2:08 PM, Zach Mullen <notifications@github.com>
wrote:

> In girder/models/setting.py:
>
> >          else:
> >              raise ValidationException(
> >                  'Invalid setting key "{}".'.format(key), 'key')
> >
> >          return doc
> >
> > -    def get(self, key, default=None):
> > +    def validate_core_plugins_enabled(self, doc):
> > +        if not type(doc['value']) is list:
> > +            raise ValidationException(
> > +                'Plugins enabled setting must be a list.', 'value')
> > +
> > +    def validate_core_cookie_lifetime(self, doc):
>
> Let's reuse our camel case method from
> https://github.com/girder/girder/blob/master/girder/utility/model_importer.py#L27
>
> That way we can keep our naming conventions consistent here.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/girder/girder/pull/359/files#r18048821>.
>