Skip to content
Myr

Merge pull request #3963 from pallets/deprecate-helpers

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

deprecate `helpers.total_seconds`

authored by David Lord · committed by GitHub · parents f3ed132, ec27677 · Browse files · 3 files+13 added−9 removed
This commit

State

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

Diff stats

3 files+13 added−9 removed

  • other:+13 added−9 removed

3 files+13 added−9 removed

modified:src/flask/helpers.py+10 added-7 removed
16 unmodified lines
17from .globals import request18from .globals import session19from .signals import message_flashed2021# what separators does this operating system provide that are not a slash?22# this is used by the send_from_directory function to ensure that nobody is23# able to access files from outside the filesystem.24_os_alt_seps = list(25 sep for sep in [os.path.sep, os.path.altsep] if sep not in (None, "/")26)212822def get_env():23 """Get the environment the app is running in, indicated by the24 :envvar:`FLASK_ENV` environment variable. The default is25 ``'production'``.
675 unmodified lines
701 :param timedelta td: the timedelta to be converted in seconds702703 :returns: number of seconds704 :rtype: int705706 .. deprecated:: 2.0707 Will be removed in Flask 2.1. Use708 :meth:`timedelta.total_seconds` instead.709 """710 warnings.warn(711 "'total_seconds' is deprecated and will be removed in Flask"712 " 2.1. Use 'timedelta.total_seconds' instead.",713 DeprecationWarning,714 stacklevel=2,715 )716 return td.days * 60 * 60 * 24 + td.seconds717718719def is_ip(value):
64 unmodified lines
modified:src/flask/sessions.py+1 added-2 removed
6 unmodified lines
7from itsdangerous import URLSafeTimedSerializer8from werkzeug.datastructures import CallbackDict910from .helpers import is_ip11from .helpers import total_seconds11from .json.tag import TaggedJSONSerializer121314class SessionMixin(MutableMapping):
323 unmodified lines
338 return None339 val = request.cookies.get(self.get_cookie_name(app))340 if not val:341 return self.session_class()343 max_age = total_seconds(app.permanent_session_lifetime)342 max_age = int(app.permanent_session_lifetime.total_seconds())343 try:344 data = s.loads(val, max_age=max_age)345 return self.session_class(data)346 except BadSignature:
39 unmodified lines
modified:CHANGES.rst+2 added
70 unmodified lines
71 teardown functions. :pr:`3412`72- Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`73- ``flask shell`` sets up tab and history completion like the default74 ``python`` shell if ``readline`` is installed. :issue:`3941`75- ``helpers.total_seconds()`` is deprecated. Use76 ``timedelta.total_seconds()`` instead. :pr:`3962`777879Version 1.1.280-------------
1011 unmodified lines