Reference

Core

The runtime heart: the application class, configuration, the request context, the shared extension registry and the constants the framework reads its switches from.

Fluid

from webfluid import Fluid — the application, a subclass of FastAPI.

  • Fluid(import_name) — constructs the app; parses config, sets up static, jinja, middleware and the optioned batteries.
  • render(template, **ctx) — async render through the context processors and the Jinja environment.
  • render_string(source, **ctx) — the same for a template you hold as a string.
  • mix() — run the app (blocking; owns the event loop, the lifecycle phases and the shutdown signals).
  • startup_hook(fn) / shutdown_hook(fn) — register lifecycle callbacks (no required args).
  • before_request(fn) / after_request(fn) / context_processor(fn) — request-level hooks.
  • add_theme(name, link) / get_theme() / set_theme(request, name) — theme management (needs WF_THEMES).
  • add_source(src, priority=1) — queue an HTML head source (a script or link) to inject into rendered pages; sources and rendered_sources read them back once frozen.
  • add_template_loader(loader) — contribute a Jinja loader before startup.
  • url_path_for(name, **params) — reverse a route through a name index.
  • limit — the slowapi limiter decorator (or a no-op when rate limiting is off).
  • config, jinja_env, name, project_root, additive_root, static_files, static_prefixes, frontend — runtime attributes.

webfluid.core.config

  • register_config(priority=1) — class decorator registering a config; priority 1–10, higher overrides lower.
  • Config — the resolved config dict; from_object pulls in upper-cased attributes.
  • DefaultConfig — the single source of truth for every framework default. Registered classes are merged on top of it, so every key it declares is present in fluid.config.
  • init_configs(fluid) / build_config() — auto-import config modules and merge the registered classes into a plain dict (used internally, and by Migrate).

webfluid.core.identity

The seam a fork edits to make the framework its own. Everything else derives from it.

  • FRAMEWORK_ID, FRAMEWORK_NAME, FRAMEWORK_ABBR, FRAMEWORK_PACKAGE, FRAMEWORK_ROOT — identity and location.
  • FRAMEWORK_SITE, FRAMEWORK_DOCS — the urls the scaffolder links to.
  • HUB_NAME, HUB_API_URL, HUB_AUTH_URL, HUB_TOKEN_FILE — the package hub.
  • CLI_NAME, ENV_PREFIX, EXTENSION_GROUP, MAIN_LOGGER, ADDITIVE_LOGGER, REQUIRES_KEY, IDENTITY_ROUTE — the names the runtime derives from the above.
  • BASE_TEMPLATE, STATIC_MOUNT, STATIC_GLOBAL, TAILWIND_GLOBAL — the template and asset names.

webfluid.core.context

  • FluidContext — the per-request context, exposing .fluid, .request and dict-like storage. current() returns it or raises; try_current() returns None instead; cached_or(key, factory) memoises a value for the request (and just calls the factory when there is no context). A context is always truthy even when it carries no data, so test the result of try_current() against None rather than relying on truthiness — len() still reports the size of its storage.
  • BaseContext — the contextvar-backed base used by the executor, babel domain, mail client and log contexts. current() / try_current() as above, and outer(depth=1) is a context manager that steps back into an enclosing one — all inherited by every subclass.

webfluid.core.ext

The shared, ready-to-use battery instances. Import the one you need:

example python
from webfluid.core.ext import (
    scheduler,  # APScheduler AsyncIOScheduler
    db,         # SQLAlchemy
    babel,      # Babel
    security,   # Security
    events,     # EventManager
    cache,      # Cache
    mail,       # Mail
    jwt         # JWTManager
)

webfluid.core.constants

The runtime flags and paths, resolved once from the environment at import time.

  • APP_STATIC, FRAMEWORK_STATIC — the static mount prefixes.
  • HUB_API, HUB_AUTH — the Ocean base urls, overridable with the OCEAN_API and OCEAN_AUTH environment variables.
  • DEBUG, EXECUTION — whether debug mode / a live run is active.
  • THEMES, TAILWIND, CHECK_FRONTEND, BUILD_FRONTEND, PROCESSING, ADDITIVES — resolved feature switches; FEATURE_FLAGS is the tuple of their environment names.
  • EXT_SCHEDULING, EXT_SQLALCHEMY, EXT_BABEL, EXT_SECURITY, EXT_EVENTS, EXT_CACHE, EXT_MAIL, EXT_JWT — resolved extension switches, with EXTENSION_FLAGS alongside them.
  • DEV_AUTO_INSTALL — run Additive.install() on every registration during a debug run.

webfluid.version

  • version() — returns the running version as a Version.
  • Version (in webfluid.utils) — a packaging.version.Version subclass built from Version(*parts), with stage and build properties on top of the usual comparison behaviour.

Continue reading

From here you can continue straight with Extensions.