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
 
13
 
14
 session_store = FilesystemSessionStore(path=SESSION_FILES_BASE_DIR, filename_template=SESSION_FILES_TEMPLATE)
14
 session_store = FilesystemSessionStore(path=SESSION_FILES_BASE_DIR, filename_template=SESSION_FILES_TEMPLATE)
15
 
15
 
16
+
16
 # TODO déplacer dans un module "sessions.py"
17
 # TODO déplacer dans un module "sessions.py"
17
 def delete_old_session_files(timestamp_now):
18
 def delete_old_session_files(timestamp_now):
18
     session_files_path = os.path.abspath(session_store.path)
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
                      if os.path.isfile(os.path.join(session_files_path, file_object))]
21
                      if os.path.isfile(os.path.join(session_files_path, file_object))]
22
+
21
     for session_file in session_files:
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
         if timestamp_now > expiration_timestamp:
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
 def is_session_file_expired(timestamp_now, sid):
30
 def is_session_file_expired(timestamp_now, sid):
30
     session_file = session_store.get_session_filename(sid)
31
     session_file = session_store.get_session_filename(sid)
31
     expiration_timestamp = os.stat(session_file).st_mtime + SESSION_EXPIRATION_LIMIT
32
     expiration_timestamp = os.stat(session_file).st_mtime + SESSION_EXPIRATION_LIMIT
33
         return False
34
         return False
34
     return True
35
     return True
35
 
36
 
37
+
36
 # WSGI Application
38
 # WSGI Application
37
 def application(env, start_response):
39
 def application(env, start_response):
38
     current_timestamp = get_utc_timestamp()
40
     current_timestamp = get_utc_timestamp()

Loading…
Cancel
Save