diff --git a/openerp/tools/config.py b/openerp/tools/config.py index d5ab9be1b81..72663b31f1c 100644 --- a/openerp/tools/config.py +++ b/openerp/tools/config.py @@ -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 = { @@ -94,6 +100,7 @@ class configmanager(object): self.casts = {} self.misc = {} + self.config_file = fname self.has_ssl = check_ssl() self._LOGLEVELS = dict([ @@ -377,7 +384,7 @@ class configmanager(object): 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