aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsource/cfg/pyAggr3g470r.cfg-sample5
-rw-r--r--source/conf.py5
-rwxr-xr-xsource/feedgetter.py3
-rw-r--r--source/mongodb.py6
-rwxr-xr-xsource/pyAggr3g470r.py3
5 files changed, 15 insertions, 7 deletions
diff --git a/source/cfg/pyAggr3g470r.cfg-sample b/source/cfg/pyAggr3g470r.cfg-sample
index 57b1627a..7300d7d5 100755
--- a/source/cfg/pyAggr3g470r.cfg-sample
+++ b/source/cfg/pyAggr3g470r.cfg-sample
@@ -1,6 +1,9 @@
[MongoDB]
-address = mongodb://username:password@127.0.0.1:27017
+address = mongodb.alwaysdata.com
port = 27017
+dbname = bob_pyaggr3g470r
+user = bob
+password = password_of_bob
[mail]
mail_from = pyAggr3g470r@no-reply.com
mail_to = address_of_the_recipient@example.com
diff --git a/source/conf.py b/source/conf.py
index 9f6724d5..726cf60d 100644
--- a/source/conf.py
+++ b/source/conf.py
@@ -39,8 +39,9 @@ path = os.path.abspath(".")
MONGODB_ADDRESS = config.get('MongoDB', 'address')
MONGODB_PORT = int(config.get('MongoDB', 'port'))
-#MONGODB_USER = config.get('MongoDB', 'user')
-#MONGODB_PASSWORD = config.get('MongoDB', 'password')
+MONGODB_DBNAME = config.get('MongoDB', 'dbname')
+MONGODB_USER = config.get('MongoDB', 'user')
+MONGODB_PASSWORD = config.get('MongoDB', 'password')
mail_from = config.get('mail','mail_from')
mail_to = config.get('mail','mail_to')
diff --git a/source/feedgetter.py b/source/feedgetter.py
index a9cdaf3e..2836656c 100755
--- a/source/feedgetter.py
+++ b/source/feedgetter.py
@@ -50,7 +50,8 @@ class FeedGetter(object):
Initializes the base and variables.
"""
# MongoDB connections
- self.articles = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT)
+ self.articles = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT, \
+ conf.MONGODB_DBNAME, conf.MONGODB_USER, conf.MONGODB_PASSWORD)
def retrieve_feed(self):
"""
diff --git a/source/mongodb.py b/source/mongodb.py
index 727d8183..fd605465 100644
--- a/source/mongodb.py
+++ b/source/mongodb.py
@@ -15,12 +15,14 @@ from operator import itemgetter, attrgetter
class Articles(object):
"""
"""
- def __init__(self, url='localhost', port=27017):
+ def __init__(self, url='localhost', port=27017, db_name="pyaggr3g470r", user="", password=""):
"""
Instantiates the connection.
"""
self.connection = pymongo.connection.Connection(url, port)
- self.db = self.connection.pyaggr3g470r
+ self.db = pymongo.database.Database(self.connection, db_name)
+ self.db.authenticate(user, password)
+ self.db = self.connection[db_name]
def add_collection(self, new_collection):
"""
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index 7b16ed18..9b5eb6ce 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -109,7 +109,8 @@ class Root:
def __init__(self):
"""
"""
- self.mongo = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT)
+ self.mongo = mongodb.Articles(conf.MONGODB_ADDRESS, conf.MONGODB_PORT, \
+ conf.MONGODB_DBNAME, conf.MONGODB_USER, conf.MONGODB_PASSWORD)
def index(self):
"""
bgstack15