No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-01 13:33:15 +01:00
src test: the sessions land where splent_feature_redis puts them once the framework resolved its settings and its init_feature built the URLs 2026-10-31 20:47:15 +01:00
.gitignore fix: ship the compiled translations, so a released feature is actually translated 2026-07-30 18:15:09 +02:00
COPYING License under LGPL-3.0-or-later 2026-10-11 11:48:06 +02:00
COPYING.LESSER License under LGPL-3.0-or-later 2026-10-11 11:48:06 +02:00
MANIFEST.in fix: ship the compiled translations, so a released feature is actually translated 2026-07-30 18:15:09 +02:00
pyproject.toml chore: release splent_io/splent_feature_session_redis to v1.3.0 2026-11-01 13:33:15 +01:00
README.md test: run the redis feature's inject_config before this one 2026-10-23 17:46:54 +02:00

splent_feature_session_redis

Server-side sessions in Redis for SPLENT products, through Flask-Session (config archetype). It is one of the session backends a product picks from; splent_feature_session_filesystem is the other. It requires splent_feature_redis, which runs the Redis server and says how to reach it.

What it does

When the app starts it sets Flask-Session to keep sessions in Redis:

  • SESSION_TYPE = "redis" and SESSION_REDIS, a client for REDIS_SESSION_URL: the server splent_feature_redis configures, with its password, on the database it keeps for sessions. Tasks and anything else stored in Redis live in other databases, so they never mix with sessions.
  • SESSION_PERMANENT = False, so a session ends with the browser unless a feature asks for more.
  • SESSION_KEY_PREFIX = "<product>:" and SESSION_COOKIE_NAME = "<product>_session", taken from SPLENT_APP. Two products served from the same host share cookies and may share one Redis, and the prefix and the cookie name keep their sessions apart.

Configuration

Where the sessions live is splent_feature_redis's to decide, so it is configured there: REDIS_URL, REDIS_PASSWORD and REDIS_SESSION_DB. This feature reads the result from app.config, never from the environment.

Setting Source Purpose
REDIS_SESSION_URL app.config, from splent_feature_redis Where the sessions are stored, password and database included.
REDIS_URL app.config, from splent_feature_redis Used when REDIS_SESSION_URL is missing, which is what splent_feature_redis 1.5 and earlier provide.
SPLENT_APP environment, else the app's package name Product name used in the key prefix and the cookie name.

With neither URL in the configuration the app does not start, and the error names the missing feature. A guessed default would only move the failure to the first request.

Tests

splent feature:test splent_feature_session_redis

The unit tests run inject_config against a bare Flask app with a mocked Redis client, so no server is needed. One runs splent_feature_redis's inject_config first, with the sessions on a database other than 0, so the two features cannot disagree on a key name without a test failing. Against a splent_feature_redis without a database per use (1.5), it is skipped.