Config.get() should accept an optional default value

RESOLVED FIXED

Status

Cloud Services
Server: Core
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: jrconlin, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [qa-])

(Reporter)

Description

7 years ago
Currently services-core.services.config.Config.get(section, item) does not accept an optional default value. This breaks the established Python behavior of dictionary like items having a default if not present.
AFAICT services.config.Config inherits from dict and has the same behaviour as dict.get, so I guess you're talking about services.config.SvcConfigParser.

In that case, maybe it's better to be consistent with ConfigParser.ConfigParser.get(), which takes a dict of defaults rather than a single value?
(In reply to Ryan Kelly [:rfkelly] from comment #1)
> AFAICT services.config.Config inherits from dict and has the same behaviour
> as dict.get, so I guess you're talking about services.config.SvcConfigParser.

This is a recent change... the Config object itself used to inherit from RawConfigParser and thus didn't support a default value.

> In that case, maybe it's better to be consistent with
> ConfigParser.ConfigParser.get(), which takes a dict of defaults rather than
> a single value?

The config parser should really be an implementation detail going forward, so my guess is that this bug is soon to be obsolete.
We cleaned up all the dictionary handling for cornice, so if there are still nastinesses in there, let's file a new bug for that.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.