plugins.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .. _plugins:
  2. Plugins
  3. =======
  4. Pagure provides a mechanism for loading 3rd party plugins in the form of Flask
  5. Blueprints. The plugins are loaded from a separate configuration file that is
  6. specified using the PAGURE_PLUGINS_CONFIG option. There are at least two
  7. reasons for keeping plugins initialization outside the main pagure
  8. configuration file:
  9. #. avoid circular dependencies errors. For example if the pagure configuration
  10. imports a plugin, which in turn imports the pagure configuration, the plugin
  11. could try to read a configuration option that has not been imported yet and
  12. thus raise an error
  13. #. the pagure configuration is also loaded by other processes such as Celery
  14. workers. The Celery tasks might only be interested in reading the
  15. configuration settings without having to load any external plugin
  16. Loading the configuration
  17. -------------------------
  18. The configuration file can be loaded by setting the variable
  19. ``PAGURE_PLUGINS_CONFIG`` inside the pagure main configuration file, for
  20. example inside ``/etc/pagure/pagure.cfg``. Alternatively, it is also possible
  21. to set the environment variable ``PAGURE_PLUGINS_CONFIG`` before starting the
  22. pagure server. If both variables are set, the environment variable takes
  23. precedence over the configuration file.
  24. The configuration file
  25. ----------------------
  26. After Pagure has imported the configuration file defined in
  27. PAGURE_PLUGINS_CONFIG it will look for Flask Blueprints in a variable called
  28. ``PLUGINS`` defined in the same file, for example
  29. ``PLUGINS = [ plugin1.blueprint, plugin2.blueprint, ... ]``. Pagure will then
  30. proceed to register any Blueprint into the main Flask app, in the same order as
  31. they are listed in ``PLUGINS``.
  32. An example configuration can be seen in ``files/plugins.cfg.sample`` inside
  33. the Pagure repository.