Skip to content
This repository
Browse code

Added total_seconds() helper for pythons before 2.7

  • Loading branch information...
commit de5038f2fb25189e6d2ba8bc479d3d940a8ea43b 1 parent 7f87091
Armin Ronacher authored

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 1 flask/sessions.py
6 flask/sessions.py
@@ -19,6 +19,10 @@
19 19 from itsdangerous import URLSafeTimedSerializer, BadSignature
20 20
21 21
  22 +def total_seconds(td):
  23 + return td.days * 60 * 60 * 24 + td.seconds
  24 +
  25 +
22 26 class SessionMixin(object):
23 27 """Expands a basic dictionary with an accessors that are expected
24 28 by Flask extensions and users for the session.
@@ -267,7 +271,7 @@ def open_session(self, app, request):
267 271 val = request.cookies.get(app.session_cookie_name)
268 272 if not val:
269 273 return self.session_class()
270   - max_age = app.permanent_session_lifetime.total_seconds()
  274 + max_age = total_seconds(app.permanent_session_lifetime)
271 275 try:
272 276 data = s.loads(val, max_age=max_age)
273 277 return self.session_class(data)

0 comments on commit de5038f

Please sign in to comment.
Something went wrong with that request. Please try again.