hooks.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. .. autofunction:: flaskbb_shell_context
  41. FlaskBB Event Hooks
  42. ~~~~~~~~~~~~~~~~~~~
  43. .. autofunction:: flaskbb_event_before_post
  44. .. autofunction:: flaskbb_event_after_post
  45. FlaskBB Form Hooks
  46. ~~~~~~~~~~~~~~~~~~
  47. .. autofunction:: flaskbb_form_new_post_save
  48. .. autofunction:: flaskbb_form_new_post
  49. Template Hooks
  50. --------------
  51. .. note::
  52. Template hooks, which are used in forms, are usually rendered after the
  53. hidden CSRF token field and before an submit field.
  54. .. autofunction:: flaskbb_tpl_navigation_before
  55. .. autofunction:: flaskbb_tpl_navigation_after
  56. .. autofunction:: flaskbb_tpl_user_nav_loggedin_before
  57. .. autofunction:: flaskbb_tpl_user_nav_loggedin_after
  58. .. autofunction:: flaskbb_tpl_form_registration_before
  59. .. autofunction:: flaskbb_tpl_form_registration_after
  60. .. autofunction:: flaskbb_tpl_form_user_details_before
  61. .. autofunction:: flaskbb_tpl_form_user_details_after
  62. .. autofunction:: flaskbb_tpl_form_new_post_before
  63. .. autofunction:: flaskbb_tpl_form_new_post_after
  64. .. autofunction:: flaskbb_tpl_profile_settings_menu
  65. .. autofunction:: flaskbb_tpl_profile_sidebar_stats
  66. .. autofunction:: flaskbb_tpl_post_author_info_before
  67. .. autofunction:: flaskbb_tpl_post_author_info_after
  68. .. autofunction:: flaskbb_tpl_admin_settings_menu