summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/__init__.py4
-rw-r--r--pykolab/base.py24
-rw-r--r--pykolab/conf/__init__.py7
3 files changed, 18 insertions, 17 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 5087bb6..df35cd1 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -197,7 +197,7 @@ class LDAP(pykolab.base.Base):
pass
retval = False
- timeout = self.config_get('timeout', 10)
+ timeout = self.config_get('timeout', default=10)
if entry_dn is None:
_search = self.ldap.search_ext(
@@ -3100,7 +3100,7 @@ class LDAP(pykolab.base.Base):
"""
if timeout is None:
- timeout = self.config_get('timeout', 10)
+ timeout = self.config_get('timeout', default=10)
supported_controls = conf.get_list('ldap', 'supported_controls')
diff --git a/pykolab/base.py b/pykolab/base.py
index f988557..ae9ab25 100644
--- a/pykolab/base.py
+++ b/pykolab/base.py
@@ -38,9 +38,9 @@ class Base(object):
self.imap = IMAP()
self.domain_rootdns = {}
- def config_get(self, key1, key2=None):
- if not key2 == None:
- return conf.get(key1, key2)
+ def config_get(self, key1, key2=None, default=None):
+ if key2 is not None:
+ return conf.get(key1, key2, default=default)
if conf.has_option(self.domain, key1):
return conf.get(self.domain, key1)
@@ -55,11 +55,11 @@ class Base(object):
if conf.has_option('kolab', key1):
return conf.get('kolab', key1)
- return None
+ return default
- def config_get_list(self, key1, key2=None):
- if not key2 == None:
- return conf.get_list(key1, key2)
+ def config_get_list(self, key1, key2=None, default=None):
+ if key2 is not None:
+ return conf.get_list(key1, key2, default=default)
if conf.has_option(self.domain, key1):
return conf.get_list(self.domain, key1)
@@ -74,11 +74,11 @@ class Base(object):
if conf.has_option('kolab', key1):
return conf.get_list('kolab', key1)
- return None
+ return default
- def config_get_raw(self, key1, key2=None):
- if not key2 == None:
- return conf.get_raw(key1, key2)
+ def config_get_raw(self, key1, key2=None, default=None):
+ if key2 is not None:
+ return conf.get_raw(key1, key2, default=default)
if conf.has_option(self.domain, key1):
return conf.get_raw(self.domain, key1)
@@ -93,5 +93,5 @@ class Base(object):
if conf.has_option('kolab', key1):
return conf.get_raw('kolab', key1)
- return None
+ return default
diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py
index 64dfbe5..16f38d8 100644
--- a/pykolab/conf/__init__.py
+++ b/pykolab/conf/__init__.py
@@ -564,7 +564,7 @@ class Conf(object):
return self.cfg_parser.has_option(section, option)
- def get_list(self, section, key):
+ def get_list(self, section, key, default=None):
"""
Gets a comma and/or space separated list from the configuration file
and returns a list.
@@ -573,13 +573,14 @@ class Conf(object):
untrimmed_values = []
setting = self.get_raw(section, key)
+
if setting is None:
- return []
+ return default if default else []
raw_values = setting.split(',')
if raw_values is None:
- return []
+ return default if default else []
for raw_value in raw_values:
untrimmed_values.extend(raw_value.split(' '))