+

Add default parameter to get_attr method

Benjamin Renard [2015-04-01 15:08:43]
Add default parameter to get_attr method
Filename
LdapServer.py
diff --git a/LdapServer.py b/LdapServer.py
index 2453ad1..611b7bd 100644
--- a/LdapServer.py
+++ b/LdapServer.py
@@ -105,17 +105,17 @@ class LdapServer(object):
 	def get_dn(self,obj):
 		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 attr in obj:
 				return obj[attr]
 			else:
-				return []
+				return default or []
 		else:
 			if attr in obj:
 				return obj[attr][0]
 			else:
-				return None
+				return default

 class LdapServerException(BaseException):
 	def __init__(self,msg):
ViewGit