flaschengeist/geruecht/controller/__init__.py

40 lines
1.3 KiB
Python

from geruecht.logger import getLogger
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:
return DatabaseController(dbConfig['URL'], dbConfig['user'], dbConfig['passwd'], dbConfig['database'])
from .ldapController import LDAPController
def getLDAPController():
if ldapController is not None:
return ldapController
else:
return LDAPController(ldapConfig['URL'], ldapConfig['dn'])
from .accesTokenController import AccesTokenController
dbConfig = config.getDatabase()
ldapConfig = config.getLDAP()
accConfig = config.getAccessToken()
db = DatabaseController(dbConfig['URL'], dbConfig['user'], dbConfig['passwd'], dbConfig['database'])
ldapController = LDAPController(ldapConfig['URL'], ldapConfig['dn'])
accesTokenController = AccesTokenController(accConfig)
from . userController import UserController
userController = UserController()