From 6c3323f2e6931cacf4250789358690ce44c90af4 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 8 Sep 2013 15:14:46 +0200 Subject: Change the name of the collection when the url of a feed is changed. --- source/mongodb.py | 2 ++ source/pyAggr3g470r.py | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'source') diff --git a/source/mongodb.py b/source/mongodb.py index 7dc83394..04cd44fa 100644 --- a/source/mongodb.py +++ b/source/mongodb.py @@ -231,6 +231,8 @@ class Articles(object): """ collection = self.db[str(feed_id)] collection.update({"type": 0, "feed_id":feed_id}, {"$set": changes}, multi=True) + if "feed_id" in changes.keys(): + self.db[str(feed_id)].rename(str(changes["feed_id"])) # Functions on database def drop_database(self): diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index bec7a9fe..007d1e6f 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -536,7 +536,12 @@ class pyAggr3g470r(object): """ Enables to change the URL of a feed already present in the database. """ + import hashlib + sha1_hash = hashlib.sha1() + sha1_hash.update(new_feed_url.encode('utf-8')) + new_feed_id = sha1_hash.hexdigest() self.mongo.update_feed(feed_id, {"feed_link":new_feed_url}) + self.mongo.update_feed(feed_id, {"feed_id":new_feed_id}) result = utils.change_feed_url(old_feed_url, new_feed_url) if result: tmpl = lookup.get_template("confirmation.html") -- cgit