Browse Source

Added documentation on the lodel/auth/exceptions.py module

Roland Haroutiounian 7 years ago
parent
commit
5d43f04276
1 changed files with 28 additions and 11 deletions
  1. 28
    11
      lodel/auth/exceptions.py

+ 28
- 11
lodel/auth/exceptions.py View File

1
+# @package lodel.auth.exceptions
2
+# @brief Defines the specific exceptions used in the authentication process
3
+
1
 from lodel.context import LodelContext
4
 from lodel.context import LodelContext
2
 
5
 
3
 LodelContext.expose_modules(globals(), {
6
 LodelContext.expose_modules(globals(), {
4
     'lodel.logger': 'logger',
7
     'lodel.logger': 'logger',
5
     'lodel.plugin.hooks': ['LodelHook']})
8
     'lodel.plugin.hooks': ['LodelHook']})
6
 
9
 
7
-##@brief Handles common errors with a Client
10
+
11
+## @brief Handles common errors with a Client
8
 class ClientError(Exception):
12
 class ClientError(Exception):
9
-    ##@brief The logger function to use to log the error message
13
+    ## @brief The logger function to use to log the error message
10
     _loglvl = 'warning'
14
     _loglvl = 'warning'
11
-    ##@brief Error str
15
+    ## @brief Error string
12
     _err_str = "Error"
16
     _err_str = "Error"
13
-    ##@brief the hook name to trigger with error
17
+    ## @brief the hook name to trigger with error
14
     _action = 'lodel2_ui_error'
18
     _action = 'lodel2_ui_error'
15
-    ##@brief the hook payload
19
+    ## @brief the hook payload
16
     _payload = None
20
     _payload = None
17
 
21
 
18
-    ##@brief Constructor
22
+    ## @brief Constructor
19
     #
23
     #
20
-    #Log message are build using the following format :
21
-    #"<client infos> : <_err_str>[ : <msg>]"
24
+    # Log messages are built using the following format :
25
+    # "<client infos> : <_err_str>[ : <msg>]"
26
+    # @param client Client : object containing the client's data
27
+    # @param msg str : message string to use
22
     def __init__(self, client, msg = ""):
28
     def __init__(self, client, msg = ""):
23
         msg = self.build_message(client, msg)
29
         msg = self.build_message(client, msg)
24
         if self._loglvl is not None:
30
         if self._loglvl is not None:
28
         if self._action is not None:
34
         if self._action is not None:
29
             LodelHook.call_hook(self._action, self, self._payload)
35
             LodelHook.call_hook(self._action, self, self._payload)
30
 
36
 
31
-    ##@brief build error message
37
+    ## @brief Builds an error message
38
+    # @param client Client
39
+    # @param msg str
32
     def build_message(self, client, msg):
40
     def build_message(self, client, msg):
33
         res = "%s : %s" % (client, self._err_str)
41
         res = "%s : %s" % (client, self._err_str)
34
         if len(msg) > 0:
42
         if len(msg) > 0:
35
             res += " : %s" % msg
43
             res += " : %s" % msg
36
         return res
44
         return res
37
 
45
 
38
-##@brief Handles authentication failure errors
46
+
47
+## @brief Handles authentication failure errors
39
 class ClientAuthenticationFailure(ClientError):
48
 class ClientAuthenticationFailure(ClientError):
49
+    ## @brief Log Level
40
     _loglvl = 'security'
50
     _loglvl = 'security'
51
+    ## @brief Error string
41
     _err_str = 'Authentication failure'
52
     _err_str = 'Authentication failure'
53
+    ## @brief Hook to trigger
42
     _action = 'lodel2_ui_authentication_failure'
54
     _action = 'lodel2_ui_authentication_failure'
43
 
55
 
44
 
56
 
45
 ##@brief Handles permission denied errors
57
 ##@brief Handles permission denied errors
46
 class ClientPermissionDenied(ClientError):
58
 class ClientPermissionDenied(ClientError):
59
+    ## @brief Log level
47
     _loglvl = 'security'
60
     _loglvl = 'security'
61
+    ## @brief Error string
48
     _err_str = 'Permission denied'
62
     _err_str = 'Permission denied'
63
+    ## @brief Hook to trigger
49
     _action = 'lodel2_ui_permission_denied'
64
     _action = 'lodel2_ui_permission_denied'
50
     
65
     
51
 
66
 
52
 ##@brief Handles common errors on authentication
67
 ##@brief Handles common errors on authentication
53
 class ClientAuthenticationError(ClientError):
68
 class ClientAuthenticationError(ClientError):
69
+    ## @brief Log level
54
     _loglvl = 'error'
70
     _loglvl = 'error'
71
+    ## @brief Error string
55
     _err_str = 'Authentication error'
72
     _err_str = 'Authentication error'
73
+    ## @brief Hook to trigger
56
     _action = 'lodel2_ui_error'
74
     _action = 'lodel2_ui_error'
57
-

Loading…
Cancel
Save