|
@@ -1,18 +1,25 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
import pymongo
|
3
|
3
|
from pymongo import MongoClient
|
|
4
|
+import urllib
|
4
|
5
|
|
5
|
|
-
|
|
6
|
+# TODO Positionner cette variable dans les settings
|
6
|
7
|
DEFAULT_CONNECTION = {
|
7
|
8
|
'host': 'localhost',
|
8
|
9
|
'port': 27017,
|
|
10
|
+ 'login': 'login', # TODO modifier la valeur
|
|
11
|
+ 'password': 'password', # TODO modifier la valeur
|
9
|
12
|
'dbname': 'lodel'
|
10
|
13
|
}
|
11
|
14
|
|
12
|
15
|
class MongoDbDataSource(object):
|
13
|
16
|
|
14
|
17
|
def __init__(self, module=pymongo, connection_args=DEFAULT_CONNECTION):
|
15
|
|
- self.connection = MongoClient(connection_args['host'], connection_args['port'])
|
|
18
|
+ connection_string = 'mongodb://%s:%s@%s:%s' % (connection_args['login'],
|
|
19
|
+ urllib.quote_plus(connection_args['password']),
|
|
20
|
+ connection_args['host'],
|
|
21
|
+ connection_args['port'])
|
|
22
|
+ self.connection = MongoClient(connection_string)
|
16
|
23
|
self.database = self.connection[connection_args['dbname']]
|
17
|
24
|
|
18
|
25
|
def insert(self):
|