blob: 497a9b3aba2c2c6cebde0070895adafa9f8ecc0a [file] [log] [blame]
import logging
from APIFactory import URIBuilder
from types import *
from notifications import *
from utils import *
__author__ = 'hanl'
# instance reference for authentication provider
# must be set before usage!
PROVIDER = None
def init_app(config):
provider_name = config.get('AUTH_PROVIDER', 'providers.CustomProvider')
split = provider_name.split('.')
# get last element, so you have the class name
_class = split[len(split) - 1]
provider_name = provider_name.replace("." + _class, "")
module = __import__(provider_name)
obj = getattr(module, _class, None)
if obj is None:
raise KeyError("the provider class '%s.%s' is undefined or could not be found!" % (provider_name, _class))
instance = obj(config)
logging.info("successfully loaded provider '%s.%s'" % (provider_name, _class))
global PROVIDER
PROVIDER = instance