splent-framework 1.18.2__tar.gz → 1.20.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. {splent_framework-1.18.2/src/splent_framework.egg-info → splent_framework-1.20.0}/PKG-INFO +2 -2
  2. {splent_framework-1.18.2 → splent_framework-1.20.0}/pyproject.toml +4 -2
  3. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/assets/asset_registry.py +53 -2
  4. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/configuration/configuration.py +16 -1
  5. splent_framework-1.20.0/src/splent_framework/decorators/decorators.py +192 -0
  6. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/fixtures/fixtures.py +12 -0
  7. splent_framework-1.20.0/src/splent_framework/layout/__init__.py +10 -0
  8. splent_framework-1.20.0/src/splent_framework/layout/shells.py +74 -0
  9. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/error_handler_manager.py +10 -4
  10. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/feature_manager.py +39 -4
  11. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/jinja_manager.py +34 -0
  12. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/security_headers_manager.py +44 -1
  13. splent_framework-1.20.0/src/splent_framework/nav/menu_registry.py +668 -0
  14. splent_framework-1.20.0/src/splent_framework/rich_text/__init__.py +66 -0
  15. splent_framework-1.20.0/src/splent_framework/rich_text/sanitize.py +430 -0
  16. splent_framework-1.20.0/src/splent_framework/translations/es/LC_MESSAGES/messages.mo +0 -0
  17. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/translations/es/LC_MESSAGES/messages.po +20 -0
  18. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/translations/messages.pot +20 -0
  19. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/path_utils.py +24 -0
  20. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/pyproject_reader.py +16 -0
  21. {splent_framework-1.18.2 → splent_framework-1.20.0/src/splent_framework.egg-info}/PKG-INFO +2 -2
  22. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework.egg-info/SOURCES.txt +13 -0
  23. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework.egg-info/requires.txt +1 -1
  24. splent_framework-1.20.0/tests/test_app_version.py +46 -0
  25. splent_framework-1.20.0/tests/test_csp_nonce.py +113 -0
  26. splent_framework-1.20.0/tests/test_has_role.py +331 -0
  27. splent_framework-1.20.0/tests/test_protected_uploads_dir.py +56 -0
  28. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_pyproject_reader.py +46 -0
  29. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_forbidden_page.py +16 -1
  30. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u4_feature_manager.py +91 -0
  31. splent_framework-1.20.0/tests/test_u5_asset_shells.py +233 -0
  32. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u6_jinja_manager.py +100 -3
  33. splent_framework-1.20.0/tests/test_u6_menu_registry.py +989 -0
  34. splent_framework-1.20.0/tests/test_u6_rich_text.py +672 -0
  35. splent_framework-1.20.0/tests/test_u6_shells.py +155 -0
  36. splent_framework-1.18.2/src/splent_framework/decorators/decorators.py +0 -48
  37. splent_framework-1.18.2/src/splent_framework/translations/es/LC_MESSAGES/messages.mo +0 -0
  38. {splent_framework-1.18.2 → splent_framework-1.20.0}/COPYING +0 -0
  39. {splent_framework-1.18.2 → splent_framework-1.20.0}/COPYING.LESSER +0 -0
  40. {splent_framework-1.18.2 → splent_framework-1.20.0}/README.md +0 -0
  41. {splent_framework-1.18.2 → splent_framework-1.20.0}/setup.cfg +0 -0
  42. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/__init__.py +0 -0
  43. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/admin/__init__.py +0 -0
  44. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/admin/registry.py +0 -0
  45. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/app_factory.py +0 -0
  46. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/assets/__init__.py +0 -0
  47. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/blueprints/__init__.py +0 -0
  48. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/blueprints/base_blueprint.py +0 -0
  49. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/bootstraps/__init__.py +0 -0
  50. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/bootstraps/locustfile_bootstrap.py +0 -0
  51. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/configuration/__init__.py +0 -0
  52. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/configuration/default_config.py +0 -0
  53. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/context/__init__.py +0 -0
  54. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/context/context_manager.py +0 -0
  55. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/db.py +0 -0
  56. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/decorators/__init__.py +0 -0
  57. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/environment/__init__.py +0 -0
  58. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/environment/host.py +0 -0
  59. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/fixtures/__init__.py +0 -0
  60. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/helpers/__init__.py +0 -0
  61. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/helpers/test_helpers_auth.py +0 -0
  62. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/hooks/__init__.py +0 -0
  63. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/hooks/template_hooks.py +0 -0
  64. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/i18n/__init__.py +0 -0
  65. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/i18n/text.py +0 -0
  66. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/locust/__init__.py +0 -0
  67. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/locust/common.py +0 -0
  68. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/__init__.py +0 -0
  69. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/config_manager.py +0 -0
  70. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/cookie_security_manager.py +0 -0
  71. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/csrf_manager.py +0 -0
  72. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/db_manager.py +0 -0
  73. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/feature_loader.py +0 -0
  74. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/feature_order.py +0 -0
  75. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/locale_manager.py +0 -0
  76. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/logging_manager.py +0 -0
  77. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/migration_manager.py +0 -0
  78. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/namespace_manager.py +0 -0
  79. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/proxy_manager.py +0 -0
  80. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/session_manager.py +0 -0
  81. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/managers/static_cache_manager.py +0 -0
  82. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/markdown/__init__.py +0 -0
  83. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/markdown/render.py +0 -0
  84. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/migrations/__init__.py +0 -0
  85. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/migrations/feature_env.py +0 -0
  86. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/namespaces/__init__.py +0 -0
  87. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/nav/__init__.py +0 -0
  88. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/nav/nav_registry.py +0 -0
  89. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/__init__.py +0 -0
  90. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/conflicts.py +0 -0
  91. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/facts.py +0 -0
  92. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/model_extender.py +0 -0
  93. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/parser.py +0 -0
  94. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/registry.py +0 -0
  95. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/templates.py +0 -0
  96. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/refinement/validator.py +0 -0
  97. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/repositories/BaseRepository.py +0 -0
  98. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/repositories/__init__.py +0 -0
  99. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/search/__init__.py +0 -0
  100. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/search/search_registry.py +0 -0
  101. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/seeders/BaseSeeder.py +0 -0
  102. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/seeders/__init__.py +0 -0
  103. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/selenium/__init__.py +0 -0
  104. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/selenium/common.py +0 -0
  105. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/services/BaseService.py +0 -0
  106. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/services/__init__.py +0 -0
  107. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/services/file_access.py +0 -0
  108. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/services/service_locator.py +0 -0
  109. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/settings/__init__.py +0 -0
  110. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/settings/settings_schema.py +0 -0
  111. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/signals/__init__.py +0 -0
  112. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/signals/registry.py +0 -0
  113. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/signals/signal_utils.py +0 -0
  114. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/__init__.py +0 -0
  115. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/app_loader.py +0 -0
  116. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/feature_utils.py +0 -0
  117. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/form_helpers.py +0 -0
  118. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/text.py +0 -0
  119. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework/utils/uvl_resolver.py +0 -0
  120. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework.egg-info/dependency_links.txt +0 -0
  121. {splent_framework-1.18.2 → splent_framework-1.20.0}/src/splent_framework.egg-info/top_level.txt +0 -0
  122. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_base_blueprint_security.py +0 -0
  123. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_base_repository.py +0 -0
  124. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_config_manager.py +0 -0
  125. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_config_manager_return.py +0 -0
  126. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_config_trace.py +0 -0
  127. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_context_manager.py +0 -0
  128. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_csrf.py +0 -0
  129. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_default_config.py +0 -0
  130. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_error_handler_manager.py +0 -0
  131. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_feature_loader_imports.py +0 -0
  132. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_feature_manager_parse.py +0 -0
  133. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_feature_order.py +0 -0
  134. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_feature_utils.py +0 -0
  135. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_helpers_host.py +0 -0
  136. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_helpers_locust.py +0 -0
  137. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_helpers_selenium.py +0 -0
  138. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_i18n_text.py +0 -0
  139. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_locale_manager.py +0 -0
  140. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_locustfile_bootstrap.py +0 -0
  141. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_markdown.py +0 -0
  142. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_migration_manager.py +0 -0
  143. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_namespace_manager.py +0 -0
  144. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_path_utils_env_file.py +0 -0
  145. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_cookies.py +0 -0
  146. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_db_engine_options.py +0 -0
  147. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_factory_integration.py +0 -0
  148. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_max_content_length.py +0 -0
  149. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_operator_settings.py +0 -0
  150. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_security_headers.py +0 -0
  151. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_prod_static_cache.py +0 -0
  152. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_proxy_manager.py +0 -0
  153. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_pyproject_reader_env.py +0 -0
  154. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement.py +0 -0
  155. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_boot.py +0 -0
  156. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_conflicts.py +0 -0
  157. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_hooks.py +0 -0
  158. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_load_order.py +0 -0
  159. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_models.py +0 -0
  160. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_routes.py +0 -0
  161. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_services.py +0 -0
  162. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_refinement_templates.py +0 -0
  163. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_search_registry.py +0 -0
  164. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_settings_schema.py +0 -0
  165. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_text.py +0 -0
  166. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_app_factory.py +0 -0
  167. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_config_manager.py +0 -0
  168. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_csrf.py +0 -0
  169. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_error_handlers.py +0 -0
  170. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_error_page_fails.py +0 -0
  171. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u1_logging_manager.py +0 -0
  172. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u2_app_loader.py +0 -0
  173. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u2_path_utils.py +0 -0
  174. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u2_session_manager.py +0 -0
  175. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u3_feature_integrator.py +0 -0
  176. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u3_feature_link_resolver.py +0 -0
  177. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u3_feature_loader.py +0 -0
  178. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u3_feature_sources_override.py +0 -0
  179. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u3_refiner_extensions.py +0 -0
  180. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u4_contracts_snapshot.py +0 -0
  181. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u4_feature_lists.py +0 -0
  182. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u5_asset_registry.py +0 -0
  183. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u5_base_blueprint.py +0 -0
  184. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u5_namespace_manager.py +0 -0
  185. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u6_admin_registry.py +0 -0
  186. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u6_markdown.py +0 -0
  187. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u6_nav_registry.py +0 -0
  188. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u6_template_hooks.py +0 -0
  189. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u7_i18n_text.py +0 -0
  190. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u7_locale_manager.py +0 -0
  191. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u7_settings_schema.py +0 -0
  192. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_feature_env.py +0 -0
  193. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_file_access.py +0 -0
  194. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_migration_logging.py +0 -0
  195. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_model_extender.py +0 -0
  196. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_service_refinement.py +0 -0
  197. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u8_signals.py +0 -0
  198. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u9_base_repository.py +0 -0
  199. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u9_base_seeder.py +0 -0
  200. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u9_file_access.py +0 -0
  201. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_u9_form_helpers.py +0 -0
  202. {splent_framework-1.18.2 → splent_framework-1.20.0}/tests/test_uvl_resolver.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: splent_framework
3
- Version: 1.18.2
3
+ Version: 1.20.0
4
4
  Summary: SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT.
5
5
  Author-email: DiversoLab <diversolab@us.es>
6
6
  License-Expression: LGPL-3.0-or-later
@@ -26,7 +26,7 @@ Requires-Dist: pytz==2024.2
26
26
  Requires-Dist: flask-babel==4.0.0
27
27
  Requires-Dist: markdown-it-py[linkify]>=3.0
28
28
  Requires-Dist: mdit-py-plugins>=0.4
29
- Requires-Dist: nh3>=0.2
29
+ Requires-Dist: nh3>=0.3
30
30
  Requires-Dist: pygments>=2.17
31
31
  Provides-Extra: dev
32
32
  Requires-Dist: pytest>=8.3; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "splent_framework"
7
- version = "1.18.2"
7
+ version = "1.20.0"
8
8
  description = "SPLENT-FRAMEWORK is a set of libraries for agile product development within SPLENT."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.13"
@@ -32,7 +32,9 @@ dependencies = [
32
32
  "flask-babel==4.0.0",
33
33
  "markdown-it-py[linkify]>=3.0",
34
34
  "mdit-py-plugins>=0.4",
35
- "nh3>=0.2",
35
+ # rich_text passes attribute_filter and markdown passes
36
+ # set_tag_attribute_values. The suite passes on 0.3.0 and 0.3.7.
37
+ "nh3>=0.3",
36
38
  "pygments>=2.17"
37
39
  ]
38
40
 
@@ -10,11 +10,26 @@
10
10
  #
11
11
  # Cleared per app at feature-load (like the nav registry) so each product only
12
12
  # emits the assets of ITS installed features. Registration is idempotent.
13
+ #
14
+ # Each asset names the shell it belongs to. A product renders through two
15
+ # shells, the public website and the signed-in application, and a stylesheet
16
+ # written for one of them breaks the other: the public reading styles and a
17
+ # skin's fonts do not belong over the panel's tables. Every asset registered
18
+ # before shells existed was written for the public shell, so that is the
19
+ # default, and a shell that asks for its assets without naming itself gets
20
+ # exactly what the public shell always got.
21
+
22
+ #: The shells an asset can be registered for. "both" serves either shell.
23
+ ASSET_SHELLS = ("public", "app", "both")
24
+ #: The shells that render pages and ask for their assets.
25
+ RENDERING_SHELLS = ("public", "app")
13
26
 
14
27
  _assets: list = []
15
28
 
16
29
 
17
- def register_asset(kind: str, endpoint: str, order: int = 100, **params) -> None:
30
+ def register_asset(
31
+ kind: str, endpoint: str, order: int = 100, *, shell: str = "public", **params
32
+ ) -> None:
18
33
  """Declare a static asset served by a feature blueprint's asset route.
19
34
 
20
35
  Args:
@@ -22,12 +37,32 @@ def register_asset(kind: str, endpoint: str, order: int = 100, **params) -> None
22
37
  endpoint: the blueprint asset endpoint, e.g. "slider.assets".
23
38
  order: load order (lower first) — governs the cascade deterministically.
24
39
  Convention: theme base ~0, features ~100, skins ~200 (win last).
40
+ shell: the shell that loads it, "public" (the default), "app" or
41
+ "both". Keyword only, so it can never be read as a url_for
42
+ argument.
25
43
  **params: url_for params for the asset route, e.g.
26
44
  subfolder="css", filename="slider.css".
45
+
46
+ Raises:
47
+ ValueError: when ``shell`` is not one of :data:`ASSET_SHELLS`.
48
+
49
+ Registering the same asset again keeps the first registration. When the
50
+ second one names the other shell, the asset serves both, so a skin that
51
+ registers one stylesheet for each shell in two calls gets what it meant.
27
52
  """
53
+ if shell not in ASSET_SHELLS:
54
+ # Before 1.20 an unknown keyword went to url_for, so shell="app"
55
+ # rendered a panel stylesheet on the public site with ?shell=app in
56
+ # its URL. A typo here must stop the boot instead.
57
+ raise ValueError(
58
+ f"register_asset({kind!r}, {endpoint!r}): shell must be 'public', "
59
+ f"'app' or 'both', not {shell!r}"
60
+ )
28
61
  key = (kind, endpoint, tuple(sorted(params.items())))
29
62
  for a in _assets:
30
63
  if a["key"] == key:
64
+ if a["shell"] != shell:
65
+ a["shell"] = "both"
31
66
  return
32
67
  _assets.append(
33
68
  {
@@ -36,23 +71,39 @@ def register_asset(kind: str, endpoint: str, order: int = 100, **params) -> None
36
71
  "endpoint": endpoint,
37
72
  "params": params,
38
73
  "order": order,
74
+ "shell": shell,
39
75
  }
40
76
  )
41
77
 
42
78
 
43
- def get_assets(kind: str) -> list:
79
+ def get_assets(kind: str, *, shell: str = "public") -> list:
44
80
  """Resolved asset URLs of a kind, ordered by (order, endpoint) and deduped.
45
81
 
82
+ ``shell`` is the shell rendering the page, "public" (the default) or
83
+ "app". It gets the assets registered for it and those registered for
84
+ "both". Without it the answer is the public shell's, which is every
85
+ asset registered without a shell, as before shells existed.
86
+
46
87
  url_for is resolved at call time, so invoke this from the template (request
47
88
  context). Assets whose route can't be resolved are skipped, not raised.
89
+
90
+ Raises:
91
+ ValueError: when ``shell`` is not one of :data:`RENDERING_SHELLS`.
48
92
  """
49
93
  from flask import url_for
50
94
 
95
+ if shell not in RENDERING_SHELLS:
96
+ raise ValueError(
97
+ f"get_assets({kind!r}): shell must be 'public' or 'app', the shell "
98
+ f"rendering the page, not {shell!r}"
99
+ )
51
100
  seen = set()
52
101
  out = []
53
102
  for a in sorted(_assets, key=lambda x: (x["order"], x["endpoint"])):
54
103
  if a["kind"] != kind:
55
104
  continue
105
+ if a.get("shell", "public") not in (shell, "both"):
106
+ continue
56
107
  try:
57
108
  href = url_for(a["endpoint"], **a["params"])
58
109
  except Exception:
@@ -1,4 +1,6 @@
1
1
  import os
2
+ from importlib import metadata
3
+
2
4
  from dotenv import load_dotenv
3
5
 
4
6
  load_dotenv()
@@ -9,12 +11,25 @@ def uploads_folder_name():
9
11
 
10
12
 
11
13
  def get_app_version():
14
+ """The running product's version.
15
+
16
+ A ``.version`` file in WORKING_DIR wins, so a deployment can stamp its own
17
+ tag. Otherwise it is the version of the installed product package, which
18
+ product:release bumps and every image installs.
19
+ """
12
20
  version_file_path = os.path.join(os.getenv("WORKING_DIR", ""), ".version")
13
21
  try:
14
22
  with open(version_file_path) as file:
15
23
  return file.readline().strip()
16
24
  except FileNotFoundError:
17
- return "unknown"
25
+ pass
26
+ product = os.getenv("SPLENT_APP")
27
+ if product:
28
+ try:
29
+ return metadata.version(product)
30
+ except metadata.PackageNotFoundError:
31
+ pass
32
+ return "unknown"
18
33
 
19
34
 
20
35
  def is_develop():
@@ -0,0 +1,192 @@
1
+ import logging
2
+ from contextlib import contextmanager
3
+ from functools import wraps
4
+
5
+ from flask import abort, current_app, request
6
+ from flask_login import current_user, login_required
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+ #: The attribute role_required puts on the view it returns: the roles the
11
+ #: screen asks for. The menu registry reads it through required_roles(), so
12
+ #: an entry that names no roles still keeps out the accounts its screen
13
+ #: would answer with 403.
14
+ REQUIRED_ROLES_ATTR = "splent_required_roles"
15
+
16
+ # Finer rules a feature brings for screens another feature gates by role.
17
+ # edition_staff lets the staff of an edition into the events and editions
18
+ # admin although their account role is plain "user", while every other panel
19
+ # screen keeps refusing them. Keyed by endpoint prefix; populated once at
20
+ # startup (init_feature) and read-only while serving, like the template hook
21
+ # registry, so it is shared by every app the process builds.
22
+ _policies: dict[str, object] = {}
23
+
24
+
25
+ def register_access_policy(endpoint_prefix: str, policy) -> None:
26
+ """Let ``policy`` decide who may open the endpoints under ``endpoint_prefix``.
27
+
28
+ ``policy(user, endpoint, view_args)`` answers True to let the account in,
29
+ False to refuse it, or None to pass. It is asked only about an account
30
+ that is signed in and active, by role_required and by has_role when given
31
+ an endpoint. Policies are asked from the longest matching prefix to the
32
+ shortest, the first one that does not pass decides, and when all pass the
33
+ roles the screen asks for decide. A policy that raises refuses.
34
+
35
+ The prefix starts with the blueprint's name and a dot, so it never covers
36
+ another blueprint whose name merely starts the same way.
37
+
38
+ Usage, from the feature's init_feature::
39
+
40
+ register_access_policy("events.admin", staff_of_some_edition)
41
+ """
42
+ blueprint, dot, _ = endpoint_prefix.partition(".")
43
+ if not blueprint or not dot:
44
+ raise ValueError(
45
+ f"access policy prefix {endpoint_prefix!r} must start with the "
46
+ "blueprint's name and a dot, for example 'events.admin'"
47
+ )
48
+ previous = _policies.get(endpoint_prefix)
49
+ if previous is not None and previous is not policy:
50
+ # Two features deciding the same screens: the later one wins, which
51
+ # may open or close more than either meant, so it is said out loud.
52
+ logger.warning(
53
+ "access policy for %r replaced: %r takes the place of %r",
54
+ endpoint_prefix,
55
+ policy,
56
+ previous,
57
+ )
58
+ _policies[endpoint_prefix] = policy
59
+
60
+
61
+ def clear_access_policies() -> None:
62
+ """Remove every registered policy. Intended for use in test teardown."""
63
+ _policies.clear()
64
+
65
+
66
+ @contextmanager
67
+ def isolated_access_policies():
68
+ """Run a block with no access policies, and put the registered ones back.
69
+
70
+ A feature's tests check its own gate this way in a product where another
71
+ feature registered a policy at startup; clearing the registry instead
72
+ would leave the rest of the test session without that policy. Policies
73
+ registered inside the block are dropped when it ends.
74
+ """
75
+ saved = dict(_policies)
76
+ _policies.clear()
77
+ try:
78
+ yield
79
+ finally:
80
+ _policies.clear()
81
+ _policies.update(saved)
82
+
83
+
84
+ def _policy_decision(endpoint: str, view_args) -> bool | None:
85
+ """What the policies covering ``endpoint`` say, or None when all pass."""
86
+ matches = sorted(
87
+ (prefix for prefix in _policies if endpoint.startswith(prefix)),
88
+ key=len,
89
+ reverse=True,
90
+ )
91
+ user = current_user._get_current_object()
92
+ for prefix in matches:
93
+ try:
94
+ decision = _policies[prefix](user, endpoint, dict(view_args or {}))
95
+ except Exception:
96
+ current_app.logger.exception(
97
+ "access policy for %r failed; refusing %s", prefix, endpoint
98
+ )
99
+ return False
100
+ if decision is not None:
101
+ return bool(decision)
102
+ return None
103
+
104
+
105
+ def pass_or_abort(condition):
106
+ def decorator(f):
107
+ @wraps(f)
108
+ def decorated_function(*args, **kwargs):
109
+ if not condition(**kwargs):
110
+ abort(404)
111
+ return f(*args, **kwargs)
112
+
113
+ return decorated_function
114
+
115
+ return decorator
116
+
117
+
118
+ def has_role(*roles, endpoint=None, view_args=None) -> bool:
119
+ """Whether the signed-in account is active and its ``role`` is in ``roles``.
120
+
121
+ The question role_required asks, for the places that must not offer a
122
+ door it would refuse: a sidebar link or a button shown to an account the
123
+ page then answers with 403. Pass the ``endpoint`` the link opens when an
124
+ access policy may cover it, so the link follows the policy too.
125
+ """
126
+ if not (
127
+ getattr(current_user, "is_authenticated", False)
128
+ and getattr(current_user, "active", False)
129
+ ):
130
+ return False
131
+ if endpoint:
132
+ decision = _policy_decision(endpoint, view_args)
133
+ if decision is not None:
134
+ return decision
135
+ return getattr(current_user, "role", None) in roles
136
+
137
+
138
+ def role_required(*roles):
139
+ """Require an authenticated, active user whose ``role`` is in ``roles``.
140
+
141
+ The shared authorization vocabulary for all features: auth contributes the
142
+ ``role`` column on User and every feature gates its screens with this
143
+ decorator. Deny by default: a user without a ``role`` attribute (older auth
144
+ versions) or with a role outside ``roles`` gets 403. An access policy
145
+ registered for the endpoint decides before the roles do (see
146
+ register_access_policy). The view it returns carries the roles, which
147
+ :func:`required_roles` reads, so a menu entry for the screen hides
148
+ itself from the accounts it would refuse. Stacked on another
149
+ role_required, it carries only the roles both of them accept.
150
+
151
+ Usage::
152
+
153
+ @bp.route("/admin/courses")
154
+ @role_required("staff", "admin")
155
+ def admin_courses():
156
+ ...
157
+ """
158
+
159
+ def decorator(f):
160
+ @wraps(f)
161
+ def wrapper(*args, **kwargs):
162
+ if not has_role(
163
+ *roles, endpoint=request.endpoint, view_args=request.view_args
164
+ ):
165
+ abort(403)
166
+ return f(*args, **kwargs)
167
+
168
+ guarded = login_required(wrapper)
169
+ # Read by required_roles(). A decorator written with functools.wraps
170
+ # on top of this one copies it along with the name. Stacked on
171
+ # another role_required, both gates ask and only the roles they
172
+ # share get through, so those are the ones the view carries.
173
+ inner = getattr(f, REQUIRED_ROLES_ATTR, None)
174
+ if inner is not None:
175
+ kept = tuple(role for role in roles if role in inner)
176
+ else:
177
+ kept = roles
178
+ setattr(guarded, REQUIRED_ROLES_ATTR, kept)
179
+ return guarded
180
+
181
+ return decorator
182
+
183
+
184
+ def required_roles(view) -> tuple | None:
185
+ """The roles ``view`` asks for through role_required, or None.
186
+
187
+ None means the view is not gated by role_required (it may still need a
188
+ signed-in account). An empty tuple is ``role_required()`` with no roles,
189
+ a screen nobody opens unless an access policy lets the account in.
190
+ """
191
+ roles = getattr(view, REQUIRED_ROLES_ATTR, None)
192
+ return None if roles is None else tuple(roles)
@@ -1,6 +1,7 @@
1
1
  import pytest
2
2
  from sqlalchemy import text
3
3
  from splent_framework.db import db
4
+ from splent_framework.decorators.decorators import isolated_access_policies
4
5
  from splent_framework.utils.app_loader import get_create_app_in_testing_mode
5
6
 
6
7
 
@@ -63,3 +64,14 @@ def clean_database(test_app):
63
64
  with test_app.app_context():
64
65
  _reset_db()
65
66
  yield
67
+
68
+
69
+ @pytest.fixture(scope="function")
70
+ def no_access_policies():
71
+ """
72
+ Runs the test with no access policies registered, and restores the ones
73
+ other features registered at startup when it ends. Use it to test a
74
+ feature's own role gate, or register a policy inside the test.
75
+ """
76
+ with isolated_access_policies():
77
+ yield
@@ -0,0 +1,10 @@
1
+ """The layouts a page extends, named by the shell they belong to.
2
+
3
+ ``shell`` is also a Jinja global::
4
+
5
+ {% extends shell('app') %}
6
+ """
7
+
8
+ from splent_framework.layout.shells import SHELL_SETTINGS, SHELL_TEMPLATES, shell
9
+
10
+ __all__ = ["SHELL_SETTINGS", "SHELL_TEMPLATES", "shell"]
@@ -0,0 +1,74 @@
1
+ # splent_framework/layout/shells.py
2
+ #
3
+ # A product renders through two shells. The application shell is the
4
+ # signed-in interface every product has, and its layout is
5
+ # base_template.html. The public shell is the website, and its layout is
6
+ # public_base.html, which splent_feature_theme ships.
7
+ #
8
+ # A page that writes the file name of its layout in {% extends %} ties
9
+ # itself to that file. shell("app") names the layout instead of the file,
10
+ # so the template that provides a shell can move (the theme takes the
11
+ # application shell over from the product's copy) or a product can point a
12
+ # shell at its own layout, and no page that extends it changes.
13
+ #
14
+ # AUTH_LOGIN_LAYOUT came first and does the same for the sign-in pages:
15
+ # a product with a public website puts its front door in it. It keeps
16
+ # working, and shell("login") reads it.
17
+
18
+ import os
19
+
20
+ from flask import current_app
21
+
22
+ #: The layout each shell resolves to when the product names none.
23
+ SHELL_TEMPLATES = {
24
+ "app": "base_template.html",
25
+ "public": "public_base.html",
26
+ }
27
+
28
+ #: The setting that points a shell at another layout.
29
+ SHELL_SETTINGS = {
30
+ "app": "SPLENT_SHELL_APP",
31
+ "public": "SPLENT_SHELL_PUBLIC",
32
+ }
33
+
34
+ # The sign-in pages: auth's AUTH_LOGIN_LAYOUT, else the application shell,
35
+ # which is where they rendered before AUTH_LOGIN_LAYOUT existed.
36
+ LOGIN = "login"
37
+ LOGIN_SETTING = "AUTH_LOGIN_LAYOUT"
38
+
39
+
40
+ def shell(name: str = "app") -> str:
41
+ """The template a page of shell ``name`` extends.
42
+
43
+ ``name`` is ``"app"``, ``"public"`` or ``"login"``. Each shell resolves
44
+ to the layout its setting names (``SPLENT_SHELL_APP``,
45
+ ``SPLENT_SHELL_PUBLIC``), read from the app config and then from the
46
+ environment, and to :data:`SHELL_TEMPLATES` when the setting is empty.
47
+ ``"login"`` resolves to ``AUTH_LOGIN_LAYOUT`` when it is set, else to
48
+ the application shell.
49
+
50
+ Raises ValueError for any other name, because a page that extends a
51
+ misspelt shell must fail where it is written rather than render in
52
+ whatever layout a fallback picked.
53
+ """
54
+ if name == LOGIN:
55
+ return _setting(LOGIN_SETTING) or shell("app")
56
+ if name not in SHELL_TEMPLATES:
57
+ raise ValueError(
58
+ f"Unknown shell {name!r}. The shells are 'app', 'public' and 'login'."
59
+ )
60
+ return _setting(SHELL_SETTINGS[name]) or SHELL_TEMPLATES[name]
61
+
62
+
63
+ def _setting(key: str) -> str:
64
+ """A template name from the app config, then the environment, or "".
65
+
66
+ The config first, so a product's config.py can fix it, and the
67
+ environment second, which is where [tool.splent.config] lands.
68
+ """
69
+ value = current_app.config.get(key)
70
+ if value is None:
71
+ value = os.getenv(key)
72
+ if not value:
73
+ return ""
74
+ return str(value).strip()
@@ -5,12 +5,15 @@ from flask import current_app, jsonify, render_template, render_template_string,
5
5
  from jinja2 import TemplateNotFound
6
6
  from werkzeug.exceptions import HTTPException, InternalServerError
7
7
 
8
+ from splent_framework.layout.shells import shell
8
9
  from splent_framework.managers.config_manager import import_product_module
9
10
 
10
11
  # The 403 the framework draws itself when neither the product nor a feature
11
- # ships one: the product's own shell, so the account keeps its sidebar and
12
+ # ships one: the application shell, so the account keeps its sidebar and
12
13
  # everything it can still do, with the copy the admin panel's 403 uses.
13
- FORBIDDEN_PAGE = """{% extends "base_template.html" %}
14
+ # ``layout`` is shell("app"), base_template.html unless SPLENT_SHELL_APP
15
+ # names another template.
16
+ FORBIDDEN_PAGE = """{% extends layout %}
14
17
  {% block title %}{{ title }}{% if site_name %} · {{ site_name }}{% endif %}{% endblock %}
15
18
  {% block head %}{{ super() }}<meta name="robots" content="noindex, nofollow">{% endblock %}
16
19
  {% block content %}
@@ -170,8 +173,10 @@ class ErrorHandlerManager:
170
173
  it gets a page, and no feature has to write a handler of its own.
171
174
  In order: the product's ``403.html``, an ``errors/403.html`` that a
172
175
  feature (a theme, a skin) ships, then the framework's page inside
173
- the product's ``base_template.html``. Without a shell, or if the
174
- page cannot be drawn, the plain 403 rather than a server error.
176
+ the application shell, ``shell("app")``, which is the product's
177
+ ``base_template.html`` unless ``SPLENT_SHELL_APP`` names another
178
+ template. Without a shell, or if the page cannot be drawn, the
179
+ plain 403 rather than a server error.
175
180
  """
176
181
  app.logger.warning("Forbidden: %s", str(e))
177
182
  try:
@@ -185,6 +190,7 @@ class ErrorHandlerManager:
185
190
  return (
186
191
  render_template_string(
187
192
  FORBIDDEN_PAGE,
193
+ layout=shell("app"),
188
194
  title=_translate("Access denied"),
189
195
  text=_translate(
190
196
  "Sign in with an account that can open this screen."
@@ -106,15 +106,16 @@ class FeatureManager:
106
106
  return
107
107
  self._registered = True
108
108
 
109
- # The nav and asset registries are process-global; clear them before
110
- # loading so the composed menu / injected assets reflect ONLY this
111
- # product's installed features (no leakage when several products'
112
- # create_app() run in one interpreter).
109
+ # The nav, menu and asset registries are process-global; clear them
110
+ # before loading so the composed menus / injected assets reflect ONLY
111
+ # this product's installed features (no leakage when several
112
+ # products' create_app() run in one interpreter).
113
113
  # The file access and search registries are cleared for a stronger
114
114
  # reason: a stale resolver left by another product would widen access
115
115
  # to protected files, or answer a search with another product's
116
116
  # material, rather than merely leak UI.
117
117
  from splent_framework.assets.asset_registry import clear_assets
118
+ from splent_framework.nav.menu_registry import clear_menus
118
119
  from splent_framework.nav.nav_registry import clear_nav_items
119
120
  from splent_framework.services.file_access import (
120
121
  clear_file_access_resolvers,
@@ -123,6 +124,7 @@ class FeatureManager:
123
124
  from splent_framework.settings.settings_schema import clear_settings_schemas
124
125
 
125
126
  clear_nav_items()
127
+ clear_menus()
126
128
  clear_assets()
127
129
  clear_settings_schemas()
128
130
  clear_file_access_resolvers()
@@ -132,6 +134,7 @@ class FeatureManager:
132
134
  product_dir = os.path.join(PathUtils.get_working_dir(), splent_app)
133
135
 
134
136
  features_raw = self._read_features(product_dir)
137
+ self._apply_layout_menu(product_dir)
135
138
  if not features_raw:
136
139
  logger.info("No features declared.")
137
140
  return
@@ -728,6 +731,38 @@ class FeatureManager:
728
731
  except (RuntimeError, ValueError) as e:
729
732
  raise FeatureError(f"Failed to parse features: {e}") from e
730
733
 
734
+ def _apply_layout_menu(self, product_dir: str) -> None:
735
+ """Put the product's [tool.splent.layout.menu] in the app config.
736
+
737
+ The menu registry reads it from app.config["SPLENT_LAYOUT_MENU"] on
738
+ every render, so the shell hides and orders the entries the product
739
+ names. A product without the table leaves the config untouched. A
740
+ malformed table stops the boot with the reason, like a malformed
741
+ feature list: a hidden entry that shows anyway is found too late.
742
+ """
743
+ from splent_framework.nav.menu_registry import (
744
+ LAYOUT_MENU_CONFIG,
745
+ parse_layout_menu,
746
+ )
747
+
748
+ reader = PyprojectReader.for_product(product_dir)
749
+ raw = reader.layout_menu
750
+ if raw is None:
751
+ return
752
+ try:
753
+ value = parse_layout_menu(raw)
754
+ except ValueError as e:
755
+ raise FeatureError(
756
+ f"[tool.splent.layout.menu] in {reader.path}: {e}"
757
+ ) from e
758
+ self._app.config[LAYOUT_MENU_CONFIG] = value
759
+ trace = self._app.extensions.setdefault("splent_config_trace", {})
760
+ trace[LAYOUT_MENU_CONFIG] = {
761
+ "value": value,
762
+ "source": "product pyproject ([tool.splent.layout.menu])",
763
+ "action": "set",
764
+ }
765
+
731
766
  def _resolve_uvl_path(self, product_dir: str) -> str | None:
732
767
  """Return the absolute path to the UVL file, or None.
733
768
 
@@ -6,6 +6,15 @@ from splent_framework.hooks.template_hooks import (
6
6
  render_template_hooks,
7
7
  )
8
8
  from splent_framework.i18n import localized
9
+ from splent_framework.layout.shells import shell
10
+ from splent_framework.managers.security_headers_manager import csp_nonce
11
+ from splent_framework.nav.menu_registry import (
12
+ menu,
13
+ menu_sections,
14
+ user_menu,
15
+ user_menu_sections,
16
+ )
17
+ from splent_framework.rich_text import safe_url, sanitize_html
9
18
  from splent_framework.settings.settings_schema import get_config, setting_value
10
19
 
11
20
 
@@ -15,6 +24,7 @@ class JinjaManager:
15
24
  self.context = context or {}
16
25
  self._register_context_processor()
17
26
  self._register_globals()
27
+ self._register_filters()
18
28
 
19
29
  def _register_context_processor(self):
20
30
  @self.app.context_processor
@@ -45,6 +55,30 @@ class JinjaManager:
45
55
  # installed, degrading to nothing otherwise: {% if
46
56
  # has_endpoint('edition_staff.admin_edition') %}…{% endif %}.
47
57
  self.app.jinja_env.globals["has_endpoint"] = self._has_endpoint
58
+ # The application shell's menus, resolved for the account being
59
+ # served: the entries it may open, the current one marked, badges
60
+ # counted. Plain data, so the shell owns all of the markup.
61
+ self.app.jinja_env.globals["menu"] = menu
62
+ self.app.jinja_env.globals["menu_sections"] = menu_sections
63
+ self.app.jinja_env.globals["user_menu"] = user_menu
64
+ self.app.jinja_env.globals["user_menu_sections"] = user_menu_sections
65
+ # The layout a page extends, by shell rather than by file name:
66
+ # {% extends shell('app') %}. See layout/shells.py.
67
+ self.app.jinja_env.globals["shell"] = shell
68
+ # The request's Content-Security-Policy nonce, for the tags a
69
+ # template owns: <script nonce="{{ csp_nonce() }}">.
70
+ self.app.jinja_env.globals["csp_nonce"] = csp_nonce
71
+
72
+ def _register_filters(self):
73
+ # HTML a feature stored, cut down to the rich text allowlist:
74
+ # {{ event.description | rich_text }}. A stored value is never
75
+ # rendered with | safe, which runs whatever it contains. The list
76
+ # and the reasons for it are in rich_text/sanitize.py.
77
+ self.app.jinja_env.filters["rich_text"] = sanitize_html
78
+ # A stored address in href or src: {{ event.link | safe_url }}
79
+ # gives "" for javascript:, data: and any scheme but http, https
80
+ # and mailto, so a bad link points nowhere instead of running.
81
+ self.app.jinja_env.filters["safe_url"] = safe_url
48
82
 
49
83
  def _has_endpoint(self, name: str) -> bool:
50
84
  return name in self.app.view_functions