deprecate total_seconds
This commit is contained in:
parent
f3ed1322a6
commit
85b430a366
3 changed files with 13 additions and 2 deletions
|
|
@ -72,6 +72,8 @@ Unreleased
|
||||||
- Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`
|
- Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`
|
||||||
- ``flask shell`` sets up tab and history completion like the default
|
- ``flask shell`` sets up tab and history completion like the default
|
||||||
``python`` shell if ``readline`` is installed. :issue:`3941`
|
``python`` shell if ``readline`` is installed. :issue:`3941`
|
||||||
|
- ``helpers.total_seconds()`` is deprecated. Use
|
||||||
|
``timedelta.total_seconds()`` instead. :pr:`3962`
|
||||||
|
|
||||||
|
|
||||||
Version 1.1.2
|
Version 1.1.2
|
||||||
|
|
|
||||||
|
|
@ -709,7 +709,17 @@ def total_seconds(td):
|
||||||
|
|
||||||
:returns: number of seconds
|
:returns: number of seconds
|
||||||
:rtype: int
|
:rtype: int
|
||||||
|
|
||||||
|
.. deprecated:: 2.0
|
||||||
|
Will be removed in Flask 2.1. Use
|
||||||
|
:meth:`timedelta.total_seconds` instead.
|
||||||
"""
|
"""
|
||||||
|
warnings.warn(
|
||||||
|
"'total_seconds' is deprecated and will be removed in Flask"
|
||||||
|
" 2.1. Use 'timedelta.total_seconds' instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
return td.days * 60 * 60 * 24 + td.seconds
|
return td.days * 60 * 60 * 24 + td.seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from itsdangerous import URLSafeTimedSerializer
|
||||||
from werkzeug.datastructures import CallbackDict
|
from werkzeug.datastructures import CallbackDict
|
||||||
|
|
||||||
from .helpers import is_ip
|
from .helpers import is_ip
|
||||||
from .helpers import total_seconds
|
|
||||||
from .json.tag import TaggedJSONSerializer
|
from .json.tag import TaggedJSONSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -340,7 +339,7 @@ class SecureCookieSessionInterface(SessionInterface):
|
||||||
val = request.cookies.get(self.get_cookie_name(app))
|
val = request.cookies.get(self.get_cookie_name(app))
|
||||||
if not val:
|
if not val:
|
||||||
return self.session_class()
|
return self.session_class()
|
||||||
max_age = total_seconds(app.permanent_session_lifetime)
|
max_age = int(app.permanent_session_lifetime.total_seconds())
|
||||||
try:
|
try:
|
||||||
data = s.loads(val, max_age=max_age)
|
data = s.loads(val, max_age=max_age)
|
||||||
return self.session_class(data)
|
return self.session_class(data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue