Browse Source

Bug Fix on the session timestamping management

Roland Haroutiounian 8 years ago
parent
commit
494be93272
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      run.py

+ 7
- 5
run.py View File

@@ -13,19 +13,20 @@ SESSION_EXPIRATION_LIMIT = 900 # 15 min
13 13
 
14 14
 session_store = FilesystemSessionStore(path=SESSION_FILES_BASE_DIR, filename_template=SESSION_FILES_TEMPLATE)
15 15
 
16
+
16 17
 # TODO déplacer dans un module "sessions.py"
17 18
 def delete_old_session_files(timestamp_now):
18 19
     session_files_path = os.path.abspath(session_store.path)
19
-    session_files = [file_object for file_object in os.listdir(session_files_path)
20
+    session_files = [os.path.join(session_files_path, file_object) for file_object in os.listdir(session_files_path)
20 21
                      if os.path.isfile(os.path.join(session_files_path, file_object))]
22
+
21 23
     for session_file in session_files:
22
-        expiration_timestamp = os.path.join(session_files_path, session_file).st_mtime + \
23
-                                                                                      SESSION_EXPIRATION_LIMIT
24
+        last_modified = os.stat(session_file).st_mtime
25
+        expiration_timestamp = last_modified + SESSION_EXPIRATION_LIMIT
24 26
         if timestamp_now > expiration_timestamp:
25
-            os.unlink(os.path.join(session_files_path, session_file))
27
+            os.unlink(session_file)
26 28
 
27 29
 
28
-# TODO Déplacer dans une module "sessions.py"
29 30
 def is_session_file_expired(timestamp_now, sid):
30 31
     session_file = session_store.get_session_filename(sid)
31 32
     expiration_timestamp = os.stat(session_file).st_mtime + SESSION_EXPIRATION_LIMIT
@@ -33,6 +34,7 @@ def is_session_file_expired(timestamp_now, sid):
33 34
         return False
34 35
     return True
35 36
 
37
+
36 38
 # WSGI Application
37 39
 def application(env, start_response):
38 40
     current_timestamp = get_utc_timestamp()

Loading…
Cancel
Save