forked from orbit-oss/flask
Merge pull request #3963 from pallets/deprecate-helpers
deprecate `helpers.total_seconds`
This commit is contained in:
commit
fab26dcbe9
3 changed files with 13 additions and 9 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
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@ from .globals import request
|
||||||
from .globals import session
|
from .globals import session
|
||||||
from .signals import message_flashed
|
from .signals import message_flashed
|
||||||
|
|
||||||
# what separators does this operating system provide that are not a slash?
|
|
||||||
# this is used by the send_from_directory function to ensure that nobody is
|
|
||||||
# able to access files from outside the filesystem.
|
|
||||||
_os_alt_seps = list(
|
|
||||||
sep for sep in [os.path.sep, os.path.altsep] if sep not in (None, "/")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_env():
|
def get_env():
|
||||||
"""Get the environment the app is running in, indicated by the
|
"""Get the environment the app is running in, indicated by the
|
||||||
|
|
@ -709,7 +702,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