diff --git a/cgi-bin/webnotes/db.py b/cgi-bin/webnotes/db.py index 1f9336c0f0..e9a96f0e2f 100644 --- a/cgi-bin/webnotes/db.py +++ b/cgi-bin/webnotes/db.py @@ -11,10 +11,12 @@ class Database: login details from `defs.py`. This is called by the request handler and is accessible using the `conn` global variable. the `sql` method is also global to run queries """ - def __init__(self, host='', user='', password='', ac_name = '', use_default = 0): + def __init__(self, host=None, user=None, password=None, ac_name=None, use_default = 0): self.host = host or 'localhost' self.user = user or getattr(defs, 'default_db_name', '') - self.password = password or getattr(defs, 'db_password', '') + + # password can be empty string + self.password = password==None and getattr(defs, 'db_password', '') or password if ac_name: self.user = self.get_db_login(ac_name) or defs.default_db_name diff --git a/cgi-bin/webnotes/utils/__init__.py b/cgi-bin/webnotes/utils/__init__.py index c438a3c08f..80f7f5af1a 100644 --- a/cgi-bin/webnotes/utils/__init__.py +++ b/cgi-bin/webnotes/utils/__init__.py @@ -462,7 +462,7 @@ def get_defaults(key=None): Get dictionary of default values from the :term:`Control Panel`, or a value if key is passed """ if key: - res = webnotes.conn.sql('select defvalue from `tabDefaultValue` where parent = "Control Panel" where defkey=%s', key) + res = webnotes.conn.sql('select defvalue from `tabDefaultValue` where parent = "Control Panel" and defkey=%s', key) return res and res[0][0] or None else: res = webnotes.conn.sql('select defkey, defvalue from `tabDefaultValue` where parent = "Control Panel"') diff --git a/cgi-bin/webnotes/utils/scheduler.py b/cgi-bin/webnotes/utils/scheduler.py index 98dea0c0cd..1f3dcb9c86 100644 --- a/cgi-bin/webnotes/utils/scheduler.py +++ b/cgi-bin/webnotes/utils/scheduler.py @@ -24,11 +24,17 @@ python [path]webnotes/utils/scheduler.py class Scheduler: def connect(self): + """ + Connect to the 'master_schduler' database + """ if hasattr(self,'conn'): return import webnotes.defs, webnotes.db - self.conn = webnotes.db.Database(user='master_scheduler', - password= webnotes.defs.__dict__.get('scheduler_password', webnotes.defs.db_password) + + pwd = webnotes.defs.__dict__.get('scheduler_password') + if pwd==None: pwd = webnotes.defs.db_password + + self.conn = webnotes.db.Database(user='master_scheduler',password=pwd) def set(self, event, interval, recurring, db_name=None): """