hooks.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .. _hooks:
  2. Hooks
  3. =====
  4. In FlaskBB we distinguish from `Python Hooks <#python-hooks>`_ and
  5. `Template Hooks <#template-hooks>`_.
  6. Python Hooks are prefixed with ``flaskbb_`` and called are called in Python
  7. files whereas Template Hooks have to be prefixed with ``flaskbb_tpl_`` and are
  8. executed in the templates.
  9. If you miss a hook, feel free to open a new issue or create a pull
  10. request. The pull request should always contain a entry in this document
  11. with a small example.
  12. A hook needs a hook specification which are defined in
  13. :mod:`flaskbb.plugins.spec`. All hooks have to be prefixed with
  14. ``flaskbb_`` and template hooks with ``flaskbb_tpl_``.
  15. Python Hooks
  16. ------------
  17. .. currentmodule:: flaskbb.plugins.spec
  18. Application Startup Hooks
  19. ~~~~~~~~~~~~~~~~~~~~~~~~~
  20. Application startup hooks are called when the application is created,
  21. either through a WSGI server (uWSGI or gunicorn for example) or by
  22. the ``flaskbb`` command.
  23. Unless noted, all FlaskBB hooks are called after the relevant builtin
  24. FlaskBB setup has run (e.g. ``flaskbb_load_blueprints`` is called after
  25. all standard FlaskBB blueprints have been loaded).
  26. The hooks below are listed in the order they are called.
  27. .. autofunction:: flaskbb_extensions
  28. .. autofunction:: flaskbb_load_blueprints
  29. .. autofunction:: flaskbb_jinja_directives
  30. .. autofunction:: flaskbb_request_processors
  31. .. autofunction:: flaskbb_errorhandlers
  32. .. autofunction:: flaskbb_load_migrations
  33. .. autofunction:: flaskbb_load_translations
  34. .. autofunction:: flaskbb_additional_setup
  35. FlaskBB CLI Hooks
  36. ~~~~~~~~~~~~~~~~~
  37. These are hooks are only invoked when using the ``flaskbb``
  38. CLI.
  39. .. autofunction:: flaskbb_cli
  40. Template Hooks
  41. --------------
  42. .. note::
  43. Template hooks, which are used in forms, are usually rendered after the
  44. hidden CSRF token field and before an submit field.
  45. .. autofunction:: flaskbb_tpl_before_navigation
  46. .. autofunction:: flaskbb_tpl_after_navigation
  47. .. autofunction:: flaskbb_tpl_before_registration_form
  48. .. autofunction:: flaskbb_tpl_after_registration_form
  49. .. autofunction:: flaskbb_tpl_before_user_details_form
  50. .. autofunction:: flaskbb_tpl_after_user_details_form
  51. .. autofunction:: flaskbb_tpl_profile_settings_menu