flaschengeist/geruecht/controller/__init__.py

49 lines
1.6 KiB
Python
Raw Normal View History

from geruecht.logger import getLogger
2019-12-30 08:22:43 +00:00
from geruecht.configparser import ConifgParser
import os
print(os.getcwd())
config = ConifgParser('geruecht/config.yml')
LOGGER = getLogger(__name__)
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
from .databaseController import DatabaseController
def getDatabesController():
if db is not None:
return db
else:
2019-12-30 08:22:43 +00:00
return DatabaseController(dbConfig['URL'], dbConfig['user'], dbConfig['passwd'], dbConfig['database'])
from .ldapController import LDAPController
def getLDAPController():
if ldapController is not None:
return ldapController
else:
2019-12-30 08:22:43 +00:00
return LDAPController(ldapConfig['URL'], ldapConfig['dn'])
from .accesTokenController import AccesTokenController
2019-12-30 08:22:43 +00:00
dbConfig = config.getDatabase()
ldapConfig = config.getLDAP()
accConfig = config.getAccessToken()
mailConfig = config.getMail()
2019-12-30 08:22:43 +00:00
db = DatabaseController(dbConfig['URL'], dbConfig['user'], dbConfig['passwd'], dbConfig['database'])
ldapController = LDAPController(ldapConfig['URL'], ldapConfig['dn'])
2020-01-18 22:31:49 +00:00
from . emailController import EmailController
emailController = EmailController(mailConfig['URL'], mailConfig['user'], mailConfig['passwd'], mailConfig['port'], mailConfig['email'])
from . userController import UserController
2020-01-18 22:31:49 +00:00
def getUserController():
if userController is not None:
return userController
else:
return UserController()
userController = UserController()
accesTokenController = AccesTokenController(accConfig)