Browse Source

Added a default connection check in the _activate function of the mongodb datasource, to see if the plugin can connect

Roland Haroutiounian 8 years ago
parent
commit
417ce0258a
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      plugins/mongodb_datasource/__init__.py

+ 11
- 0
plugins/mongodb_datasource/__init__.py View File

@@ -1,3 +1,5 @@
1
+from .utils import connect, get_connection_args
2
+
1 3
 __loader__ = "main.py"
2 4
 __confspec__ = "confspec.py"
3 5
 __author__ = "Lodel2 dev team"
@@ -10,4 +12,13 @@ __fullname__ = "MongoDB plugin"
10 12
 #
11 13
 # @return bool|str : True if all the checks are OK, an error message if not
12 14
 def _activate():
15
+    default_connection_args = get_connection_args()
16
+    connection_check = connect(
17
+        default_connection_args['host'],
18
+        default_connection_args['port'],
19
+        default_connection_args['db_name'],
20
+        default_connection_args['username'],
21
+        default_connection_args['password'])
22
+    if not connection_check:
23
+        return False
13 24
     return True

Loading…
Cancel
Save