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.

__init__.py 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. ## @defgroup lodel2_plugins Plugins
  20. # @ingroup lodel2_leapi
  21. #
  22. # Groups all stuff that concerns plugins
  23. ## @page plugin_doc Lodel2 plugin documentation
  24. # @ingroup lodel2_plugins
  25. # @section plugin_doc_type Plugin types
  26. #
  27. # In Lodel2, plugins are organized into types. Each type helps specifying a
  28. # behavior. As of now, we have four plugin types :
  29. # - **datasource** : a connector exposing C.R.U.D. (Create/Read/Update/Delete)
  30. # operations on a particular datasource (a database, a remote service, etc ...)
  31. # - **ui** : a user interface that will provide a way to interact with Lodel2.
  32. # As of now, we have the following "ui" plugins :
  33. # - interactive python : the default interface, provides access to LeApi
  34. # through an interactive python interpreter
  35. # - webui : a web interface to lodel2
  36. # - **session_handler** : handles user sessions
  37. # - **extensions** : a basic plugin that will extend Lodel2 functionalities.
  38. # It can define two kinds of objects :
  39. # - hooks using @ref lodel.plugin.hooks.LodelHook decorator
  40. # - custom LeApi obect methods using @ref lodel.plugin.plugins.CustomMethod
  41. # decorator
  42. #
  43. # @subsection Lodel2 scripts
  44. #
  45. # In every instances of Lodel, one can use a manager script to execute some
  46. # defined administration commands that can be launched as CLI commands.
  47. # This utility script is provided by @ref install.lodel_admin. The syntax
  48. # to execute it is :
  49. # <code>usage: lodel_admin.py [-h] [-L] [ACTION] [OPTIONS [OPTIONS ...]]</code>
  50. #
  51. # Each action is a "lodel2 script". All those scripts are parts of plugins.
  52. # @ref lodel2_script "More informations on lodel2 scripting utilities"
  53. #
  54. # @section plugin_doc_struct Common plugin structure
  55. #
  56. # All plugin, whatever its type, has to provide mandatory informations in
  57. # order to be loaded :
  58. # - A plugin name
  59. # - A plugin version
  60. # - A confspec indicating where to find the wanted plugin list (for example
  61. # datasources plugins list are indicated in lodel2.datasource_connectors
  62. # configuration key see @ref datasource_plugin.DatasourcePlugin::_plist_confspecs ).
  63. #  In fact settings MUST begin by loading wanted plugin list in order to build a "full" confspec
  64. # - A confspec indicating the plugins allowed settings (will be merged with lodel2 confspecs)
  65. # - A loader module filename. This module is imported once settings are fully bootstraped and loader.
  66. # It triggers the module "startup".
  67. #
  68. # In order to provide these informations, the developper can use the plugin's
  69. # package <code>__init__.py</code> file. Some informations are stored in
  70. # variables in this file. Available variables are documented in
  71. # @ref plugin_init_specs . Here a list of basics variables :
  72. # - the plugin's name @ref plugins.PLUGIN_NAME_VARNAME
  73. # - the plugin's version @ref plugins.PLUGIN_VERSION_VARNAME
  74. # - the plugin's loader filename @ref plugins.LOADER_FILENAME_VARNAME
  75. # - the plugin's confspec filename @ref plugins.CONFSPEC_FILENAME_VARNAME
  76. # (set this variable only if you want your confspecs to be in a separated file,
  77. # else you can put the confspecs directly in a CONFSPEC variable in the
  78. # <code>__init__.py</code> file see @ref plugins.CONFSPEC_VARNAME )
  79. # - the plugin's type @ref plugins.PLUGIN_TYPE_VARNAME (if not set use
  80. # @ref plugins.DEFAULT_PLUGIN_TYPE )
  81. # - the plugin's dependencies list @ref plugins.PLUGIN_DEPS_VARNAME
  82. #
  83. # This was the variable specification of the <code>__init__.py</code> file.
  84. # plugins can provide (in the same file) an _activate function (
  85. # <code>def _activate(): returns bool</code>) that return True if the plugin
  86. # is activable else False
  87. #
  88. #An example dummy plugin exists in @ref plugins.dummy
  89. #
  90. #@section plugin_doc_childclasses Plugin types implementation
  91. #
  92. # Concretely a plugin type is a child class of @ref plugins.Plugin . Plugin
  93. # type registration is done automatically using a metaclass for
  94. # @ref plugins.Plugin : @ref plugins.MetaPlugType . Doing this way
  95. # plugin's type list is automatically generated.
  96. #@note Plugin type handling is not fully automatic because child classes files
  97. #are not automaticaaly imported. We have to add an import instruction into
  98. #@ref plugin file in order to trigger the registration
  99. #
  100. #The Plugin child class must set the _plist_confspecs class attribute.
  101. #
  102. #More informations :
  103. # - @ref lodel.plugin.datasource_plugin.DatasourcePlugin "DatasourcePlugin"
  104. # - @ref lodel2_datasources "datasources"
  105. # - @ref lodel.plugin.extensions.Extension "Extensions"
  106. # - @ref lodel.plugin.interface.InterfacePlugin "InterfacePlugin"
  107. # - @ref lodel.plugin.sessionhandler.SessionHandlerPlugin "SessionHandlerPlugin"
  108. from lodel.context import LodelContext
  109. LodelContext.expose_modules(globals(), {
  110. 'lodel.plugin.hooks': ['LodelHook'],
  111. 'lodel.plugin.plugins': ['Plugin', 'CustomMethod'],
  112. 'lodel.plugin.datasource_plugin': ['DatasourcePlugin'],
  113. 'lodel.plugin.sessionhandler': ['SessionHandlerPlugin'],
  114. 'lodel.plugin.interface': ['InterfacePlugin'],
  115. 'lodel.plugin.extensions': ['Extension']})