Jason R. Coombs  committed b6ae71c

Added SelectableStorage and migration support to rss.FeedparserDB

  • Participants
  • Parent commits 16713d3

Comments (0)

Files changed (1)

File pmxbot/

 			print, "Oh crap, couldn't add_feed_entries"
 			print e
+class FeedparserDB(storage.SelectableStorage):
+	pass
-class FeedparserDB(storage.SQLiteStorage):
+class SQLiteFeedparserDB(FeedparserDB, storage.SQLiteStorage):
 	def init_tables(self):
 		self.db.execute("CREATE TABLE IF NOT EXISTS feed_seen (key varchar)")
 		self.db.execute('CREATE INDEX IF NOT EXISTS ix_feed_seen_key ON feed_seen (key)')
 		self.db.executemany('INSERT INTO feed_seen (key) values (?)', [(x,) for x in entries])
-class MongoDBFeedparserDB(storage.MongoDBStorage):
+	export_all = get_seen_feeds
+class MongoDBFeedparserDB(FeedparserDB, storage.MongoDBStorage):
 	collection_name = 'feed history'
 	def get_seen_feeds(self):
 		return [row['key'] for row in self.db.find()]
 		for entry in entries:
+	def import_(self, item):
+		self.add_entries([item])
 def init_feedparser_db(uri):
-	class_ = MongoDBFeedparserDB if uri.startswith('mongodb://') else FeedparserDB
-	return class_(uri)
+	return FeedparserDB.from_URI(uri)