Skip to content

Commit

Permalink
[IMP] config: accept rc folders
Browse files Browse the repository at this point in the history
rcfolders are a flexible way to decouple config items according to their
invidual lifecycle. That means that mix and match config straegies using
magic [DEFAULT] become possible.

This avoides wrapping the ini-config API in cases where two sets of conig items
origin from two different sources.

Eg.: ConfigMaps
  • Loading branch information
David Arnold committed Dec 3, 2018
1 parent a4cbfbe commit baba813
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion odoo/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ def die(cond, msg):

self.rcfile = os.path.abspath(
self.config_file or opt.config or os.environ.get('ODOO_RC') or os.environ.get('OPENERP_SERVER') or rcfilepath)
if os.path.isdir(self.rcfile):
self.rcfiles = sorted([os.path.join(self.rcfile, f) for f in os.listdir(self.rcfile) if os.path.isfile(os.path.join(self.rcfile, f))])
else:
self.rcfiles = [self.rcfile]
self.load()

# Verify that we want to log or not, if not the output will go to stdout
Expand Down Expand Up @@ -537,7 +541,7 @@ def load(self):
}
p = ConfigParser.RawConfigParser()
try:
p.read([self.rcfile])
p.read(self.rcfiles)
for (name,value) in p.items('options'):
name = outdated_options_map.get(name, name)
if value=='True' or value=='true':
Expand All @@ -562,6 +566,8 @@ def load(self):
pass

def save(self):
if os.path.isdir(self.rcfile):
sys.stderr.write("ERROR: cannot write out config file when using config directories\n")
p = ConfigParser.RawConfigParser()
loglevelnames = dict(zip(self._LOGLEVELS.values(), self._LOGLEVELS))
p.add_section('options')
Expand Down

0 comments on commit baba813

Please sign in to comment.