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 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ## @package lodel.plugins.dummy.main Plugin's loader module
  20. from lodel.context import LodelContext
  21. LodelContext.expose_modules(globals(), {
  22. 'lodel.plugin': ['LodelHook', 'CustomMethod'],
  23. 'lodel.settings' : 'settings'})
  24. ## @brief callback method using lodel's hook system
  25. # @param hook_name str
  26. # @param caller function : action to perform
  27. # @param payload : data to pass to the caller
  28. # @return payload
  29. @LodelHook('leapi_get_post')
  30. @LodelHook('leapi_update_pre')
  31. @LodelHook('leapi_update_post')
  32. @LodelHook('leapi_delete_pre')
  33. @LodelHook('leapi_delete_post')
  34. @LodelHook('leapi_insert_pre')
  35. @LodelHook('leapi_insert_post')
  36. def dummy_callback(hook_name, caller, payload):
  37. if settings.Settings.debug:
  38. print("\tHook %s\tcaller %s with %s" % (hook_name, caller, payload))
  39. return payload
  40. ## @brief instance method
  41. # This is an example of a basic plugin's custom method
  42. @CustomMethod('Object', 'dummy_method')
  43. def dummy_instance_method(self):
  44. print("Hello world !\
  45. I'm a custom method on an instance of class %s" % self.__class__)
  46. ## @brief instance method
  47. # This is an example of a basic plugin's custom method
  48. @CustomMethod('Object', 'dummy_class_method', CustomMethod.CLASS_METHOD)
  49. def dummy_instance_method(self):
  50. print("Hello world !\
  51. I'm a custom method on class %s" % self.__class__)