Browse Source

Documentation on the filesystem session plugin

Roland Haroutiounian 7 years ago
parent
commit
b53986d16d

+ 2
- 0
lodel/plugins/filesystem_session/__init__.py View File

@@ -1,3 +1,5 @@
1
+## @package plugins.filesystem_session This package is a plugin for filesystem based session management
2
+
1 3
 from lodel.context import LodelContext
2 4
 LodelContext.expose_modules(globals(), {
3 5
     'lodel.validator.validator': ['Validator']})

+ 3
- 0
lodel/plugins/filesystem_session/confspec.py View File

@@ -1,9 +1,12 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
+## @package lodel.plugins.filesystem_session.confspec A module that defines the configuration options available for that plugin
4
+
3 5
 from lodel.context import LodelContext
4 6
 LodelContext.expose_modules(globals(), {
5 7
     'lodel.validator.validator': ['Validator']})
6 8
 
9
+## @brief Dictionary of the options and their corresponding validators
7 10
 CONFSPEC = {
8 11
     'lodel2.sessions':{
9 12
         'directory': ('/tmp/', Validator('path')),

+ 2
- 1
lodel/plugins/filesystem_session/filesystem_session.py View File

@@ -1,10 +1,11 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
+## @package lodel.plugins.filesystem_session.filesystem_session Session objects management module
3 4
 
4 5
 ## @brief An extended dictionary representing a session in the file system
5 6
 class FileSystemSession(dict):
6 7
 
7
-    ## @brief Constructor
8
+    ##
8 9
     # @param token str
9 10
     def __init__(self, token):
10 11
         self.__token = token

+ 21
- 4
lodel/plugins/filesystem_session/main.py View File

@@ -1,4 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2
+
3
+## @package lodel.plugins.filesystem_session.main Main entry point of the plugin
4
+
2 5
 import binascii
3 6
 import datetime
4 7
 import os
@@ -30,18 +33,24 @@ def generate_token():
30 33
 
31 34
 ## @brief checks the validity of a given session token
32 35
 # @param token str
33
-# @raise ClientAuthenticationFailure for invalid or not found session token
36
+# @throw ClientAuthenticationFailure for invalid or not found session token
34 37
 def check_token(token):
35 38
     if len(token) != SESSION_TOKENSIZE:
36 39
         raise ClientAuthenticationFailure("Invalid token string")
37 40
     if token not in __sessions.keys():
38 41
         raise ClientAuthenticationFailure("No session found for this token")
39 42
 
43
+
40 44
 ## @brief returns a session file path for a specific token
45
+# @param token str
46
+# @return str
41 47
 def generate_file_path(token):
42 48
     return os.path.abspath(os.path.join(Settings.sessions.directory, Settings.sessions.file_template) % token)
43 49
 
44 50
 
51
+##
52
+# @param filepath str
53
+# @return str|None : returns the token or None if no token was found
45 54
 def get_token_from_filepath(filepath):
46 55
     token_regex = re.compile(os.path.abspath(os.path.join(Settings.sessions.directory, Settings.sessions.file_template % '(?P<token>.*)')))
47 56
     token_search_result = token_regex.match(filepath)
@@ -53,7 +62,7 @@ def get_token_from_filepath(filepath):
53 62
 ## @brief returns the session's last modification timestamp
54 63
 # @param token str
55 64
 # @return float
56
-# @raise ValueError if the given token doesn't match with an existing session
65
+# @throw ValueError if the given token doesn't match with an existing session
57 66
 def get_session_last_modified(token):
58 67
     if token in __sessions[token]:
59 68
         return os.stat(__sessions[token]).st_mtime
@@ -138,17 +147,25 @@ def gc():
138 147
                 logger.debug("Expired session %s has been destroyed" % token)
139 148
 
140 149
 
150
+##
151
+# @param token str
152
+# @param key str
153
+# @param value
141 154
 def set_session_value(token, key, value):
142 155
     session = restore_session(token)
143 156
     session[key] = value
144 157
     save_session(token, session)
145 158
 
146
-
159
+##
160
+# @param token str
161
+# @param key str
147 162
 def get_session_value(token, key):
148 163
     session = restore_session(token)
149 164
     return session[key]
150 165
 
151
-
166
+##
167
+# @param token str
168
+# @param key str
152 169
 def del_session_value(token, key):
153 170
     session = restore_session(token)
154 171
     if key in session:

Loading…
Cancel
Save