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.

lefactory_common.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  3. #
  4. # Copyright (C) 2015-2017 Cléo UMS-3287
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published
  8. # by the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. #-
  20. #- THE CONTENT OF THIS FILE IS DESIGNED TO BE INCLUDED IN DYNAMICALLY
  21. #- GENERATED CODE
  22. #-
  23. #- All lines that begins with #- will be deleted from dynamically generated
  24. #- code...
  25. ##@brief Returns a dynamically generated class given its name
  26. #@param name str : The dynamic class name
  27. #@return False or a child class of LeObject
  28. def name2class(name):
  29. if name not in dynclasses_dict:
  30. return False
  31. return dynclasses_dict[name]
  32. ##@brief Returns a dynamically generated class given its name
  33. #@note Case insensitive version of name2class
  34. #@param name str
  35. #@return False or a child class of LeObject
  36. def lowername2class(name):
  37. name = name.lower()
  38. new_dict = {k.lower():v for k,v in dynclasses_dict.items()}
  39. if name not in new_dict:
  40. return False
  41. return new_dict[name]
  42. ##@brief Triggers dynclasses datasources initialisation
  43. @LodelHook("lodel2_plugins_loaded")
  44. def lodel2_dyncode_datasources_init(self, caller, payload):
  45. for cls in dynclasses:
  46. cls._init_datasources()
  47. LodelContext.expose_modules(globals(), {'lodel.plugin.hooks': ['LodelHook']})
  48. LodelHook.call_hook("lodel2_dyncode_loaded", __name__, dynclasses)