Beaker is a Python library providing robust caching and session management functionality, including WSGI middleware for web applications and decorators for standalone scripts. It supports various back-ends like file, memory, Memcached, Redis, MongoDB, and SQLAlchemy. The library is actively maintained, with the current stable version being 1.13.0.
pip install beakerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate Beaker's `SessionMiddleware` with a basic WSGI application. It configures a file-based session to track a counter across requests. Make sure the `data_dir` and `lock_dir` paths exist or are writable by the application.
Create the specified directories and set appropriate permissions (e.g., `os.makedirs('./data/sessions/data', exist_ok=True)`) or choose different backend types suitable for your deployment.Configure `session.data_serializer = 'json'` in your session options. Ensure all data stored in the session is JSON-serializable. Otherwise, only store basic, trusted, and serializable Python types.
For production environments, use persistent backends like `file`, `dbm`, `memcached`, `redis`, or `mongodb` for session storage to ensure data survives process restarts.
Upgrade Beaker to version 1.9.1 or higher. The fix was included in release 1.9.1 (2018-04-09).
Ensure your WSGI application is wrapped by `SessionMiddleware` with proper configuration, e.g., `application = SessionMiddleware(your_app, session_opts)`.
Refactor your code to store only primitive types or objects that are known to be pickleable. Alternatively, configure Beaker to use a different serializer: `session_opts = {..., 'session.data_serializer': 'json'}` (if your data is JSON-compatible).Upgrade the Beaker library to version 1.9.1 or later (`pip install --upgrade beaker`) to resolve the keyword conflict.
No dependency data recorded yet.