From 143de38d7e50e23f6f8d7977692b218f45c6753d Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 4 Mar 2012 09:06:43 +0100 Subject: Unread articles page is now completely working. Improvements of the get_articles_from_collection() function in mongodb.py, the function takes now an aditional argument in order to filter the result. --- mongodb.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mongodb.py') diff --git a/mongodb.py b/mongodb.py index 2da229c8..1f74d164 100644 --- a/mongodb.py +++ b/mongodb.py @@ -80,12 +80,15 @@ class Articles(object): feeds = sorted(feeds, key=itemgetter('feed_title')) return feeds - def get_articles_from_collection(self, feed_id): + def get_articles_from_collection(self, feed_id, condition=None): """ Return all the articles of a collection. """ collection = self.db[str(feed_id)] - cursor = collection.find({"type":1}) + if condition is None: + cursor = collection.find({"type":1}) + else: + cursor = collection.find({"type":1, condition[0]:condition[1]}) return cursor.sort([("article_date", pymongo.DESCENDING)]) def print_articles_from_collection(self, collection_id): -- cgit