pypaginate.engine.cursor_codec

Cursor value encoding/decoding for keyset pagination.

Encodes ORDER BY column values into URL-safe base64 strings. No external dependencies — uses stdlib json + base64.

Functions

decode_cursor(→ tuple[Any, Ellipsis])

Decode a cursor string back to a values tuple.

encode_cursor(→ str)

Encode cursor values to a URL-safe string.

Module Contents

pypaginate.engine.cursor_codec.decode_cursor(cursor: str) tuple[Any, Ellipsis]

Decode a cursor string back to a values tuple.

Raises:

ValidationError – If the cursor is malformed or tampered with.

pypaginate.engine.cursor_codec.encode_cursor(values: tuple[Any, Ellipsis]) str

Encode cursor values to a URL-safe string.

Uses the native paginate-core extension when available, falling back to the pure-Python codec. The wire format is identical either way.