mirror of https://github.com/pallets/flask.git
deprecate total_seconds
This commit is contained in:
parent
f3ed1322a6
commit
85b430a366
|
@ -72,6 +72,8 @@ Unreleased
|
|||
- Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`
|
||||
- ``flask shell`` sets up tab and history completion like the default
|
||||
``python`` shell if ``readline`` is installed. :issue:`3941`
|
||||
- ``helpers.total_seconds()`` is deprecated. Use
|
||||
``timedelta.total_seconds()`` instead. :pr:`3962`
|
||||
|
||||
|
||||
Version 1.1.2
|
||||
|
|
|
@ -709,7 +709,17 @@ def total_seconds(td):
|
|||
|
||||
:returns: number of seconds
|
||||
: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
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ from itsdangerous import URLSafeTimedSerializer
|
|||
from werkzeug.datastructures import CallbackDict
|
||||
|
||||
from .helpers import is_ip
|
||||
from .helpers import total_seconds
|
||||
from .json.tag import TaggedJSONSerializer
|
||||
|
||||
|
||||
|
@ -340,7 +339,7 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
val = request.cookies.get(self.get_cookie_name(app))
|
||||
if not val:
|
||||
return self.session_class()
|
||||
max_age = total_seconds(app.permanent_session_lifetime)
|
||||
max_age = int(app.permanent_session_lifetime.total_seconds())
|
||||
try:
|
||||
data = s.loads(val, max_age=max_age)
|
||||
return self.session_class(data)
|
||||
|
|
Loading…
Reference in New Issue