From bab0ad457e53d401ed3eb0c5381d6933bfb596f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Mar 2009 01:14:48 +0100 Subject: [PATCH] Don't start the server if init or update without database option --- trytond/config.py | 4 ++-- trytond/server.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/trytond/config.py b/trytond/config.py index e850a20186..154f8be1fb 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -102,14 +102,14 @@ class ConfigManager(object): self.options['db_name'] = db_name init = {} - if opt.init and self.options.get('db_name'): + if opt.init: for i in opt.init.split(','): if i != 'tests': init[i] = 1 self.options['init'] = init update = {} - if opt.update and self.options.get('db_name'): + if opt.update: for i in opt.update.split(','): if i != 'tests': update[i] = 1 diff --git a/trytond/server.py b/trytond/server.py index 5ec33d9f70..8a657110a8 100644 --- a/trytond/server.py +++ b/trytond/server.py @@ -70,6 +70,11 @@ class TrytonServer(object): update = False init = {} + + if not CONFIG["db_name"] \ + and bool(CONFIG['init'] or CONFIG['update']): + raise Exception('Missing database option!') + for db_name in CONFIG["db_name"]: init[db_name] = False database = Database(db_name).connect()