Sin descripción
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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. # Plugins are organized into types. A type specify a behavior. For the moment
  11. # Lodel2 has 4 plugin types :
  12. # - **datasource** : A datasource connector plugin expose CRUD operation on a
  13. #particular datasource
  14. # - **ui** : A user interface plugin provide an interface to lodel2. For the
  15. #moment two ui are implemented
  16. # - interactive python : the default interface, provides access to LeApi
  17. #through interactive python interpreter
  18. # - webui : a plugin providing a web interface to lodel2
  19. # - **session_handler** : A session handler plugin expose functions that handles
  20. #user sessions.
  21. # - **extensions** : An extension plugin can define 2 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 instances an utility is provided : @ref install.lodel_admin . This
  29. # utility can be runned as a CLI script
  30. #<code>usage: lodel_admin.py [-h] [-L] [ACTION] [OPTIONS [OPTIONS ...]]</code>
  31. #
  32. # Each actions is a "lodel2 script". Thoses scripts are parts of plugins.
  33. # @ref lodel2_script "More informations on lodel2 scripting utilities"
  34. #
  35. # @section plugin_doc_struct Common plugin structure
  36. #
  37. # All plugin types has to provide mandatories information in order to be
  38. # loaded :
  39. #
  40. # - A plugin name
  41. # - A plugin version
  42. # - A confspec indicating where to find the wanted plugin list (for example
  43. #datasources plugins list are indicated in lodel2.datasource_connectors
  44. #configuration key see @ref datasource_plugin.DatasourcePlugin::_plist_confspecs ). In
  45. #fact settings MUST begin by loading wanted plugin list in order to build
  46. #a "full" confspec
  47. # - A confspec indicating the plugins allowed settings (will be merged with
  48. #lodel2 confspecs)
  49. # - A loader module filename. This module is imported once settings are
  50. #fully bootstraped and loader. It triggers the module "startup".
  51. #
  52. # In order to provide this informations the develloper can use the plugin's
  53. #package <code>__init__.py</code> file. Some informations are stored in
  54. #variables in this file. Available variables are documented in
  55. #@ref plugin_init_specs . Here a list of basics variables :
  56. # - the plugin's name @ref plugins.PLUGIN_NAME_VARNAME
  57. # - the plugin's version @ref plugins.PLUGIN_VERSION_VARNAME
  58. # - the plugin's loader filename @ref plugins.LOADER_FILENAME_VARNAME
  59. # - the plugin's confspec filename @ref plugins.CONFSPEC_FILENAME_VARNAME (
  60. #set this variable only if you want your confspecs to be in a separated file,
  61. #else you can put the confspecs directly in a CONFSPEC variable in the
  62. #<code>__init__.py</code> file see @ref plugins.CONFSPEC_VARNAME )
  63. # - the plugin's type @ref plugins.PLUGIN_TYPE_VARNAME (if not set use
  64. # @ref plugins.DEFAULT_PLUGIN_TYPE )
  65. # - the plugin's dependencies list @ref plugins.PLUGIN_DEPS_VARNAME
  66. #
  67. # This was the variable specification of the <code>__init__.py</code> file.
  68. #plugins can provide (in the same file) an _activate function (
  69. #<code>def _activate(): returns bool</code>) that return True if the plugin
  70. #is activable else False
  71. #
  72. #An example dummy plugin exists in @ref plugins.dummy
  73. #
  74. #@section plugin_doc_childclasses Plugin types implementation
  75. #
  76. # Concretely a plugin type is a child class of @ref plugins.Plugin . Plugin
  77. # type registration is done automatically using a metaclass for
  78. # @ref plugins.Plugin : @ref plugins.MetaPlugType . Doing this way
  79. # plugin's type list is automatically generated.
  80. #@note Plugin type handling is not fully automatic because child classes files
  81. #are not automaticaaly imported. We have to add an import instruction into
  82. #@ref plugin file in order to trigger the registration
  83. #
  84. #The Plugin child class must set the _plist_confspecs class attribute.
  85. #
  86. #More informations :
  87. # - @ref lodel.plugin.datasource_plugin.DatasourcePlugin "DatasourcePlugin"
  88. # - @ref lodel2_datasources "datasources"
  89. # - @ref lodel.plugin.extensions.Extension "Extensions"
  90. # - @ref lodel.plugin.interface.InterfacePlugin "InterfacePlugin"
  91. # - @ref lodel.plugin.sessionhandler.SessionHandlerPlugin "SessionHandlerPlugin"
  92. #
  93. from lodel.context import LodelContext
  94. LodelContext.expose_modules(globals(), {
  95. 'lodel.plugin.hooks': ['LodelHook'],
  96. 'lodel.plugin.plugins': ['Plugin', 'CustomMethod'],
  97. 'lodel.plugin.datasource_plugin': ['DatasourcePlugin'],
  98. 'lodel.plugin.sessionhandler': ['SessionHandlerPlugin'],
  99. 'lodel.plugin.interface': ['InterfacePlugin'],
  100. 'lodel.plugin.extensions': ['Extension']})