aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-04-22 22:22:06 +0200
committercedricbonhomme <devnull@localhost>2012-04-22 22:22:06 +0200
commitc5ceae44b5b1f3d6f20497ebca81042f85fd3178 (patch)
treec62609e3a18d8998f05aed8e6d442bec166ae424
parentRemoved print_collections() function. (diff)
downloadnewspipe-c5ceae44b5b1f3d6f20497ebca81042f85fd3178.tar.gz
newspipe-c5ceae44b5b1f3d6f20497ebca81042f85fd3178.tar.bz2
newspipe-c5ceae44b5b1f3d6f20497ebca81042f85fd3178.zip
Renamed get_collection() to get_feed().
-rw-r--r--source/mongodb.py19
-rwxr-xr-xsource/pyAggr3g470r.py14
2 files changed, 13 insertions, 20 deletions
diff --git a/source/mongodb.py b/source/mongodb.py
index a12b6146..bb4fbf2b 100644
--- a/source/mongodb.py
+++ b/source/mongodb.py
@@ -2,13 +2,12 @@
# -*- coding: utf-8 -*-
__author__ = "Cedric Bonhomme"
-__version__ = "$Revision: 0.1 $"
+__version__ = "$Revision: 0.2 $"
__date__ = "$Date: 2012/03/03 $"
-__revision__ = "$Date: 2012/03/03 $"
+__revision__ = "$Date: 2012/04/22 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
-import time
import pymongo
from operator import itemgetter, attrgetter
@@ -58,8 +57,9 @@ class Articles(object):
collection = self.db[str(feed_id)]
collection.find_and_modify(query={"article_id":article_id}, remove=True)
- def get_collection(self, feed_id):
+ def get_feed(self, feed_id):
"""
+ Return information about a feed.
"""
return self.db[str(feed_id)].find().next()
@@ -192,8 +192,6 @@ class Articles(object):
if __name__ == "__main__":
# Point of entry in execution mode.
articles = Articles()
-
-
# Create a collection for a stream
collection_dic = {"collection_id": 42,\
"feed_image": "Image", \
@@ -202,11 +200,8 @@ if __name__ == "__main__":
"site_title": "Site link", \
"mail": True, \
}
-
#articles.add_collection(collection_dic)
-
-
# Add an article in the newly created collection
article_dic1 = {"article_id": 51, \
"article_date": "Today", \
@@ -216,7 +211,6 @@ if __name__ == "__main__":
"article_readed": True, \
"article_like": True \
}
-
article_dic2 = {"article_id": 52, \
"article_date": "Yesterday", \
"article_link": "Link", \
@@ -225,13 +219,12 @@ if __name__ == "__main__":
"article_readed": True, \
"article_like": True \
}
-
+
#articles.add_articles([article_dic1, article_dic2], 42)
-
+
print "All articles:"
#print articles.get_all_articles()
-
# Drop the database
articles.drop_database() \ No newline at end of file
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py
index 4b363cdb..9d1f98b1 100755
--- a/source/pyAggr3g470r.py
+++ b/source/pyAggr3g470r.py
@@ -432,7 +432,7 @@ class Root:
"""
try:
feed_id, article_id = param.split(':')
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
articles = self.mongo.get_articles_from_collection(feed_id)
article = self.mongo.get_article(feed_id, article_id)
except:
@@ -575,7 +575,7 @@ class Root:
favourite articles for the current feed.
"""
try:
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
articles = self.mongo.get_articles_from_collection(feed_id)
except KeyError:
return self.error_page("This feed do not exists.")
@@ -704,7 +704,7 @@ class Root:
This page displays all articles of a feed.
"""
try:
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
articles = self.mongo.get_articles_from_collection(feed_id)
except KeyError:
return self.error_page("This feed do not exists.")
@@ -800,7 +800,7 @@ class Root:
# List unread articles of a feed
else:
try:
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
except:
self.error_page("This feed do not exists.")
html += """<h1>Unread article(s) of the feed <a href="/articles/%s">%s</a></h1>
@@ -929,7 +929,7 @@ class Root:
"""
try:
feed_id, article_id = target.split(':')
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
article = self.mongo.get_article(feed_id, article_id)
except:
return self.error_page("Bad URL. This article do not exists.")
@@ -1111,7 +1111,7 @@ class Root:
html += htmlnav
html += """<div class="left inner">"""
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
self.mongo.delete_feed(feed_id)
utils.remove_feed(feed["feed_link"])
@@ -1237,7 +1237,7 @@ class Root:
return self.error_page("Bad URL.")
try:
feed_id, article_id = param.split(':')
- feed = self.mongo.get_collection(feed_id)
+ feed = self.mongo.get_feed(feed_id)
articles = self.mongo.get_articles_from_collection(feed_id)
article = self.mongo.get_article(feed_id, article_id)
except:
bgstack15