From 1484d6382f1efa44149874bbf4ca3bee93f75d24 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Mon, 22 Aug 2016 11:28:25 +0200 Subject: [PATCH] Allow to pass many configuration files issue4780 review27471002 --- CHANGELOG | 1 + bin/trytond | 2 +- doc/topics/start_server.rst | 3 +++ trytond/commandline.py | 3 ++- trytond/config.py | 4 ++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 782c35c9b5..62a328ecf5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow to pass many configuration files * Remove translate on field name of User * Allow to define the default mode in calendar view * Use 'default_rec_name' context key in Model.default_get diff --git a/bin/trytond b/bin/trytond index 2c7d2eeffa..f5b6cf491f 100755 --- a/bin/trytond +++ b/bin/trytond @@ -38,7 +38,7 @@ with commandline.pidfile(options): ssl_context = (certificate, privatekey) else: ssl_context = None - extra_files = [options.configfile] + extra_files = options.configfile for module in get_module_list(): info = get_module_info(module) path = os.path.join(info['directory'], 'view', '*.xml') diff --git a/doc/topics/start_server.rst b/doc/topics/start_server.rst index 71853ba4d9..dcd446f8dd 100644 --- a/doc/topics/start_server.rst +++ b/doc/topics/start_server.rst @@ -14,6 +14,9 @@ You can start the default web server bundled in Tryton with this command line:: The server will wait for client connections on the interface defined in the `web` section of the :ref:`configuration `. +.. note:: When using multiple config files the order is importart as last + entered files will override the items of first files + WSGI server ----------- diff --git a/trytond/commandline.py b/trytond/commandline.py index 81f52d84d3..cd0dfd252b 100644 --- a/trytond/commandline.py +++ b/trytond/commandline.py @@ -18,7 +18,8 @@ def get_parser(): parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) parser.add_argument("-c", "--config", dest="configfile", metavar='FILE', - default=os.environ.get('TRYTOND_CONFIG'), help="specify config file") + nargs='+', default=[os.environ.get('TRYTOND_CONFIG')], + help='Specify configuration files') parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="enable verbose mode") parser.add_argument('--dev', dest='dev', action='store_true', diff --git a/trytond/config.py b/trytond/config.py index 7a0d0a2236..61c38b3d18 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -70,8 +70,8 @@ class TrytonConfigParser(ConfigParser.RawConfigParser): def update_etc(self, configfile=os.environ.get('TRYTOND_CONFIG')): if not configfile: return - logger.info('using %s as configuration file', configfile) - self.read(configfile) + read_files = self.read(configfile) + logger.info('using %s as configuration files', ', '.join(read_files)) def get(self, section, option, *args, **kwargs): default = kwargs.pop('default', None)