diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index fe6a98d..dff12c0 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -107,7 +107,7 @@ class LdapCherry(object): except: raise BackendModuleLoadingFail(module) try: - self.backends[backend] = bc.Backend(params, cherrypy.log) + self.backends[backend] = bc.Backend(params, cherrypy.log, backend) except: raise BackendModuleInitFail(module) diff --git a/ldapcherry/backend/__init__.py b/ldapcherry/backend/__init__.py index a671873..e9b8887 100644 --- a/ldapcherry/backend/__init__.py +++ b/ldapcherry/backend/__init__.py @@ -5,6 +5,8 @@ # LdapCherry # Copyright (c) 2014 Carpentier Pierre-Francois +from ldapcherry.exceptions import MissingParameter + class Backend: def __init__(self): @@ -21,3 +23,12 @@ class Backend: def rm_from_group(self): pass + + def get_param(self, param, default=False): + if param in self.config: + return self.config[param] + elif default: + return default + else: + raise MissingParameter(self.backend_name+'.'+param, 'backends') + diff --git a/ldapcherry/backend/backendSamba4.py b/ldapcherry/backend/backendSamba4.py index 8f490e1..3c56935 100644 --- a/ldapcherry/backend/backendSamba4.py +++ b/ldapcherry/backend/backendSamba4.py @@ -9,5 +9,5 @@ import ldapcherry.backend class Backend(ldapcherry.backend.Backend): - def __init__(self, config, logger): + def __init__(self, config, logger, name): pass