Skip to main content

Requirements

  • Python 3.6+
  • FastHTML 0.4.0+

Issues and Contributions

If you encounter any issues or have suggestions for improvements, please use the GitHub Issues page to report them.

Usage

SessionNormalizerMiddleware provides a drop-in replacement for the standard fasthtml session middleware class. This session middleware class aggressively converts session stored data to a format that can be serialized.

Simple example:

from fasthtml_sessionnormalizer.middleware import SessionNormalizerMiddleware
from fasthtml import FastHTML


app = FastHTML(sess_cls=SessionNormalizerMiddleware)

@app.get("/")
def default(session, item_id: UUID):
    session["item_id"] = item_id

The above endpoint will successfully store a UUID object in the session, converting it to a string before returning it to the user. Note: objects that only provide a __str__ method that matches that of the default object class as the sole mechanism of conversion will not be serialized, as the assumption is that the default string representation of an object provides no meaningful semantic data to be persisted in a user session. Other mechanisms of conversion that the middleware will try to use include custom __str__ methods, __dict__ attributes, __json__ attributes, and other common mechanisms that allow for an object to be represented in such a way as to be serialized.

Contributing

This project is open for contributions from the public. If you see any room for improvement, open an issue with your suggestion and we can discuss it.

Metadata

Release files for fasthtml-sessionnormalizer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fasthtml-sessionnormalizer 0.1.0
File Size Uploaded
fasthtml_sessionnormalizer-0.1.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fasthtml-sessionnormalizer 0.1.0
File Interpreter ABI Platform
fasthtml_sessionnormalizer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / fasthtml_sessionnormalizer-0.1.0.tar.gz

Download URL fasthtml_sessionnormalizer-0.1.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d30ab4b08286fd8365031473769c70243f337e94b64cb1a6b93694d6127d490
BLAKE2b-256 checksum
How to use checksums
a1f426db49bf165291bd35a0ab8d9cdff4c7663e83786175787327b41479b645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.7-arch1-1

Release files / fasthtml_sessionnormalizer-0.1.0-py3-none-any.whl

Download URL fasthtml_sessionnormalizer-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
274e9ecf2194cf2cc00bdfdbb73f429ffe208e497c3e7340cd2558c9345dee38
BLAKE2b-256 checksum
How to use checksums
c721e570e66edc11c72014bf92b38fbf03a3e2640ef7b12cc42622d25067c235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.7-arch1-1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page