Skip to content

Commit

Permalink
Reintroduce fname kwarg in configmanager
Browse files Browse the repository at this point in the history
In [f04f409], the configmanager's __init__ lost its fname kwarg, which
allows to pass the name of the config file to read (or write).
Without it the only way to programmatically specify this file name is to
use the OPENERP_SERVER environment variable, which may be unpractical and/or
subject to renaming.

External tools (such as the buildout recipe) may need to pass this file in a
clean way.
  • Loading branch information
Georges Racinet authored and antonylesuisse committed Dec 16, 2014
1 parent a9b4c56 commit 9dad29c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openerp/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ def _get_default_datadir():
return func(appname=release.product_name, appauthor=release.author)

class configmanager(object):
def __init__(self):
def __init__(self, fname=None):
"""Constructor.
:param fname: a shortcut allowing to instantiate :class:`configmanager`
from Python code without resorting to environment
variable
"""
# Options not exposed on the command line. Command line options will be added
# from optparse's parser.
self.options = {
Expand All @@ -94,6 +100,7 @@ def __init__(self):
self.casts = {}

self.misc = {}
self.config_file = fname
self.has_ssl = check_ssl()

self._LOGLEVELS = dict([
Expand Down Expand Up @@ -377,7 +384,7 @@ def die(cond, msg):
rcfilepath = os.path.expanduser('~/.openerp_serverrc')

self.rcfile = os.path.abspath(
opt.config or os.environ.get('OPENERP_SERVER') or rcfilepath)
self.config_file or opt.config or os.environ.get('OPENERP_SERVER') or rcfilepath)
self.load()

# Verify that we want to log or not, if not the output will go to stdout
Expand Down

0 comments on commit 9dad29c

Please sign in to comment.