Ei kuvausta
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 4.9KB

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