From 09aeb1c823455efb5b563b7416a855dfc1dd26ce Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sat, 20 Oct 2012 15:52:06 +0200 Subject: Catch an error when creating index with mongodb and python 2.7.3. --- source/mongodb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/mongodb.py b/source/mongodb.py index 8d1a4848..8d07bf38 100644 --- a/source/mongodb.py +++ b/source/mongodb.py @@ -55,8 +55,11 @@ class Articles(object): """ collection = self.db[str(feed_id)] - collection.create_index([("article_date", pymongo.DESCENDING)], \ + try: + collection.create_index([("article_date", pymongo.DESCENDING)], \ {"unique":False, "sparse":False}) + except: + print "Oups" for article in articles: cursor = collection.find({"article_id":article["article_id"]}) -- cgit