No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.py 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. #-*- coding: utf-8 -*-
  2. from lodel.plugin import LodelHook
  3. from lodel.settings import Settings
  4. from lodel import logger
  5. ##@brief Bootstrap hook to check datasources configuration
  6. @LodelHook('lodel2_bootstraped')
  7. def datasources_bootstrap_callaback(hook_name, caller, payload):
  8. for ds_name in Settings.datasources._fields:
  9. ds_conf = getattr(Settings.datasources, ds_name)
  10. identifier = getattr(ds_conf, 'identifier')
  11. # Now we are trying to fetch the datasource given the identifier
  12. ds_family_name, ds_name = identifier.split('.',1)
  13. try:
  14. ds_fam = getattr(Settings.datasource, ds_family_name)
  15. except AttributeError:
  16. msg = "No datasource family named '%s' found"
  17. msg %= ds_family_name
  18. raise NameError(msg)
  19. try:
  20. ds = getattr(ds_fam, ds_name)
  21. except AttributeError:
  22. msg = "No datasource configured for identifier '%s' found"
  23. msg %= identifier
  24. raise NameError(msg)
  25. log_msg = "Found a datasource named '%s' identified by '%s'"
  26. log_msg %= (ds_name, identifier)
  27. logger.debug(log_msg)