fixes to scheduler, get_defaults and defs to accept empty password:

This commit is contained in:
Rushabh Mehta 2011-07-15 14:13:51 +05:30
parent 7670902f94
commit bc1544ea3e
3 changed files with 13 additions and 5 deletions

View file

@ -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

View file

@ -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"')

View file

@ -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):
"""