From 4954299061ec4c08a1e72f8ee86dd2c9e8775690 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 26 Aug 2010 21:24:40 +0100 Subject: [PATCH] add default attribute to appropriate database element if missing --- pyfpdb/Configuration.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 29b74b54..1349581d 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -688,6 +688,7 @@ class Config: raise ValueError("Database names must be unique") if self.db_selected is None or db.db_selected: self.db_selected = db.db_name + db_node.setAttribute("default", "True") self.supported_databases[db.db_name] = db #TODO: if the user may passes '' (empty string) as database name via command line, his choice is ignored # ..when we parse the xml we allow for ''. there has to be a decission if to allow '' or not @@ -972,9 +973,10 @@ class Config: if db_user is not None: db_node.setAttribute("db_user", db_user) if db_pass is not None: db_node.setAttribute("db_pass", db_pass) if db_server is not None: db_node.setAttribute("db_server", db_server) - if defaultb: db_node.setAttribute("default", default) + if defaultb or self.db_selected == db_name: + db_node.setAttribute("default", True) elif db_node.hasAttribute("default"): - db_node.removeAttribute("default") + db_node.removeAttribute("default") if self.supported_databases.has_key(db_name): if db_desc is not None: self.supported_databases[db_name].dp_desc = db_desc if db_ip is not None: self.supported_databases[db_name].dp_ip = db_ip