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.

core_hooks.py 1.4KB

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