Skip to content
Myr

use generic bases for session (#5638)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 7b21d43, f49dbfd · Browse files · 1 file+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−5 removed

  • other:+7 added−5 removed

1 file+7 added−5 removed

modified:src/flask/sessions.py+7 added-5 removed
1from __future__ import annotations23import collections.abc as c4import hashlib5import typing as t6from collections.abc import MutableMapping7from datetime import datetime
12 unmodified lines
20 from .wrappers import Request21 from .wrappers import Response222323# TODO generic when Python > 3.824class SessionMixin(MutableMapping): # type: ignore[type-arg]24class SessionMixin(MutableMapping[str, t.Any]):25 """Expands a basic dictionary with session attributes."""2627 @property28 def permanent(self) -> bool:
19 unmodified lines
48 #: coded to ``True``.49 accessed = True505152# TODO generic when Python > 3.853class SecureCookieSession(CallbackDict, SessionMixin): # type: ignore[type-arg]52class SecureCookieSession(CallbackDict[str, t.Any], SessionMixin):53 """Base class for sessions based on signed cookies.5455 This session backend will set the :attr:`modified` and56 :attr:`accessed` attributes. It cannot reliably track whether a
13 unmodified lines
70 #: header, which allows caching proxies to cache different pages for71 #: different users.72 accessed = False7375 def __init__(self, initial: t.Any = None) -> None:74 def __init__(75 self,76 initial: c.Mapping[str, t.Any] | c.Iterable[tuple[str, t.Any]] | None = None,77 ) -> None:78 def on_update(self: te.Self) -> None:79 self.modified = True80 self.accessed = True81
317 unmodified lines