Skip to content
Myr

PERMANENT_SESSION_LIFETIME can now be an integer. This fixes #310

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 6d0b326 · Browse files · 3 files+35 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+35 added−9 removed

  • other:+35 added−9 removed

3 files+35 added−9 removed

modified:docs/api.rst+7 added
215 unmodified lines
216217.. autoclass:: SessionMixin218 :members:219220.. admonition:: Notice221222 The ``PERMANENT_SESSION_LIFETIME`` config key can also be an integer223 starting with Flask 0.8. Either catch this down yourself or use224 the :attr:`~flask.Flask.permanent_session_lifetime` attribute on the225 app which converts the result to an integer automatically.226227228Test Client229-----------230231.. currentmodule:: flask.testing
393 unmodified lines
modified:docs/config.rst+2 added
84 unmodified lines
85 with the secure flag. Defaults to86 `False`.87``PERMANENT_SESSION_LIFETIME`` the lifetime of a permanent session as88 :class:`datetime.timedelta` object.89 Starting with Flask 0.8 this can also be90 an integer representing seconds.91``USE_X_SENDFILE`` enable/disable x-sendfile92``LOGGER_NAME`` the name of the logger93``SERVER_NAME`` the name and port number of the server.94 Required for subdomain support (e.g.:
289 unmodified lines
modified:flask/app.py+26 added-9 removed
175 unmodified lines
176 #: This attribute can also be configured from the config with the177 #: `SESSION_COOKIE_NAME` configuration key. Defaults to ``'session'``178 session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME')179180 #: A :class:`~datetime.timedelta` which is used to set the expiration181 #: date of a permanent session. The default is 31 days which makes a182 #: permanent session survive for roughly one month.183 #:184 #: This attribute can also be configured from the config with the185 #: `PERMANENT_SESSION_LIFETIME` configuration key. Defaults to186 #: ``timedelta(days=31)``187 permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME')188180 #: Enable this if you want to use the X-Sendfile feature. Keep in181 #: mind that the server has to support this. This only affects files182 #: sent with the :func:`send_file` method.183 #:
301 unmodified lines
485 if rv is not None:486 return rv487 return self.debug488489 def _get_permanent_session_lifetime(self):490 """A :class:`~datetime.timedelta` which is used to set the expiration491 date of a permanent session. The default is 31 days which makes a492 permanent session survive for roughly one month.493494 This attribute can also be configured from the config with the495 `PERMANENT_SESSION_LIFETIME` configuration key. Defaults to496 ``timedelta(days=31)``.497498 If you want to have this value as seconds you can use ``total_seconds()``::499500 app.permanent_session_lifetime.total_seconds()501502 Note that the config key can be a timedelta object or number of seconds503 as integer since Flask 0.8.504 """505 rv = self.config['PERMANENT_SESSION_LIFETIME']506 if not isinstance(rv, timedelta):507 return timedelta(seconds=rv)508 return rv509 def _set_permanent_session_lifetime(self, value):510 self.config['PERMANENT_SESSION_LIFETIME'] = value511 permanent_session_lifetime = property(_get_permanent_session_lifetime,512 _set_permanent_session_lifetime)513 del _get_permanent_session_lifetime, _set_permanent_session_lifetime514515 @property516 def logger(self):517 """A :class:`logging.Logger` object for this application. The518 default configuration is to log to stderr if the application is
1010 unmodified lines