Add default parameter to get_attr method

This commit is contained in:
Benjamin Renard 2015-04-01 17:08:43 +02:00
parent 4faaf2c3ad
commit de9472a08a

View file

@ -105,17 +105,17 @@ class LdapServer(object):
def get_dn(self,obj): def get_dn(self,obj):
return obj[0][0] return obj[0][0]
def get_attr(self,obj,attr,all=None): def get_attr(self,obj,attr,all=None,default=None):
if all is not None: if all is not None:
if attr in obj: if attr in obj:
return obj[attr] return obj[attr]
else: else:
return [] return default or []
else: else:
if attr in obj: if attr in obj:
return obj[attr][0] return obj[attr][0]
else: else:
return None return default
class LdapServerException(BaseException): class LdapServerException(BaseException):
def __init__(self,msg): def __init__(self,msg):