Extension points

Every feature declares which parts of itself are safe to override. This is the [tool.splent.contract.extensible] section in pyproject.toml.

Table of contents

What it means

“These parts of my feature can be overridden or extended by a refinement feature.” If a refiner tries to override something not listed here, the framework raises an error at startup.


Example: auth

[tool.splent.contract.extensible]
services  = ["AuthenticationService"]
templates = ["auth/login_form.html", "auth/signup_form.html"]
models    = ["User"]
hooks     = ["layout.anonymous_sidebar", "layout.authenticated_sidebar",
             "layout.navbar.anonymous", "layout.navbar.authenticated"]
routes    = true

Categories

Category Meaning
services Service classes replaceable via the service locator
templates Jinja templates overridable by a refiner’s blueprint
models SQLAlchemy models extendable with mixin columns/methods
hooks Template hooks that can be replaced (not just appended to)
routes If true, refiners can add new routes to this feature’s blueprint

Auto-inference

feature:contract --write and feature:release auto-generate the extensible section from source code:

  • services, models — from class definitions in services.py and models.py
  • templates — from HTML files in templates/
  • hooks — from register_template_hook() calls and get_template_hooks() slots in templates
  • routestrue if the feature defines a blueprint

The section is always regenerated from source. To restrict what can be overridden, remove the code rather than editing the TOML.


See also


Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es