Browse Source

Added comments on filesystem session plugin's modules

Roland Haroutiounian 8 years ago
parent
commit
48f295998b

+ 9
- 0
plugins/filesystem_session/filesystem_session.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 
2
 
3
 
3
 
4
+## @brief An extended dictionary representing a session in the file system
4
 class FileSystemSession(dict):
5
 class FileSystemSession(dict):
5
 
6
 
7
+    ## @brief Constructor
8
+    # @param token str
6
     def __init__(self, token):
9
     def __init__(self, token):
7
         self.__token = token
10
         self.__token = token
8
         self.__path = None
11
         self.__path = None
9
 
12
 
13
+    ## @brief token getter
14
+    # @return str
10
     @property
15
     @property
11
     def token(self):
16
     def token(self):
12
         return self.__token
17
         return self.__token
13
 
18
 
19
+    ## @brief path getter
20
+    # @return str
14
     @property
21
     @property
15
     def path(self):
22
     def path(self):
16
         return self.__path
23
         return self.__path
17
 
24
 
25
+    ## @brief path setter
26
+    # @param path str
18
     @path.setter
27
     @path.setter
19
     def path(self, path):
28
     def path(self, path):
20
         self.__path = path
29
         self.__path = path

+ 9
- 1
plugins/filesystem_session/main.py View File

16
 
16
 
17
 SESSION_TOKENSIZE = 150
17
 SESSION_TOKENSIZE = 150
18
 
18
 
19
+
19
 ## @brief generates a new session token
20
 ## @brief generates a new session token
20
 # @return str
21
 # @return str
21
 def generate_token():
22
 def generate_token():
34
     if token not in __sessions.keys():
35
     if token not in __sessions.keys():
35
         raise ClientAuthenticationFailure("No session found for this token")
36
         raise ClientAuthenticationFailure("No session found for this token")
36
 
37
 
37
-
38
+## @brief returns a session file path for a specific token
38
 def generate_file_path(token):
39
 def generate_file_path(token):
39
     return os.path.abspath(os.path.join(Settings.sessions.directory, Settings.sessions.file_template) % token)
40
     return os.path.abspath(os.path.join(Settings.sessions.directory, Settings.sessions.file_template) % token)
40
 
41
 
81
     logger.debug("Session %s unregistered" % token)
82
     logger.debug("Session %s unregistered" % token)
82
 
83
 
83
 
84
 
85
+## @brief restores a session's content
86
+# @param token str
87
+# @return FileSystemSession|None
84
 def restore_session(token):
88
 def restore_session(token):
85
     gc()
89
     gc()
86
     check_token(token)
90
     check_token(token)
93
         return None  # raise FileNotFoundError("Session file not found for the token %s" % token)
97
         return None  # raise FileNotFoundError("Session file not found for the token %s" % token)
94
 
98
 
95
 
99
 
100
+## @brief saves the session's content to a file
101
+# @param token str
102
+# @param datas dict
96
 def save_session(token, datas):
103
 def save_session(token, datas):
97
     session = datas
104
     session = datas
98
     if not isinstance(datas, FileSystemSession):
105
     if not isinstance(datas, FileSystemSession):
109
     logger.debug("Session %s saved" % token)
116
     logger.debug("Session %s saved" % token)
110
 
117
 
111
 
118
 
119
+## @brief session store's garbage collector
112
 def gc():
120
 def gc():
113
     # Unregistered files in the session directory
121
     # Unregistered files in the session directory
114
     session_files_directory = os.path.abspath(Settings.sessions.directory)
122
     session_files_directory = os.path.abspath(Settings.sessions.directory)

Loading…
Cancel
Save