Remove direct references to PodcastChannel and PodcastEpisode

This will come in handy when subclassing the model classes.
This commit is contained in:
Thomas Perl 2010-12-20 15:17:48 +01:00
parent be1c1114a2
commit dedc1d1aba
4 changed files with 503 additions and 495 deletions

View File

@ -26,7 +26,7 @@ integrate podcast functionality into their applications.
import gpodder
from gpodder import util
from gpodder import opml
from gpodder.model import PodcastChannel
from gpodder.model import Model
from gpodder import download
from gpodder import dbsqlite
@ -182,7 +182,7 @@ class PodcastClient(object):
Returns all the subscribed podcasts from gPodder.
"""
return [Podcast(p, self) for p in PodcastChannel.load_from_db(self._db)]
return [Podcast(p, self) for p in Model.get_podcasts(self._db)]
def get_podcast(self, url):
"""Get a specific podcast by URL
@ -191,7 +191,7 @@ class PodcastClient(object):
the podcast has not been subscribed to.
"""
url = util.normalize_feed_url(url)
channel = PodcastChannel.load(self._db, url, create=False)
channel = Model.load_podcast(self._db, url, create=False)
if channel is None:
return None
else:
@ -205,7 +205,7 @@ class PodcastClient(object):
the resulting object.
"""
url = util.normalize_feed_url(url)
podcast = PodcastChannel.load(self._db, url, create=True, \
podcast = Model.load_podcast(self._db, url, create=True, \
max_episodes=self._config.max_episodes_per_feed, \
mimetype_prefs=self._config.mimetype_prefs)
if podcast is not None:
@ -222,7 +222,6 @@ class PodcastClient(object):
This has to be called from the API user after
data-changing actions have been carried out.
"""
podcasts = PodcastChannel.load_from_db(self._db)
self._db.commit()
return True

View File

@ -79,8 +79,7 @@ from gpodder.liblogger import log
_ = gpodder.gettext
N_ = gpodder.ngettext
from gpodder.model import PodcastChannel
from gpodder.model import PodcastEpisode
from gpodder.model import Model
from gpodder.dbsqlite import Database
from gpodder.gtkui.model import PodcastListModel
@ -444,7 +443,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
# Subscribed channels
self.active_channel = None
self.channels = PodcastChannel.load_from_db(self.db)
self.channels = Model.get_podcasts(self.db)
self.channel_list_changed = True
self.update_podcasts_tab()
@ -2243,7 +2242,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
def playback_episodes(self, episodes):
# We need to create a list, because we run through it more than once
episodes = list(PodcastEpisode.sort_by_pubdate(e for e in episodes if \
episodes = list(Model.sort_episodes_by_pubdate(e for e in episodes if \
e.was_downloaded(and_exists=True) or self.streaming_possible()))
try:
@ -2585,7 +2584,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
episodes.extend(podcast.get_all_episodes())
if episodes:
episodes = list(PodcastEpisode.sort_by_pubdate(episodes, \
episodes = list(Model.sort_episodes_by_pubdate(episodes, \
reverse=True))
self.new_episodes_show(episodes, \
selected=[e.check_is_new() for e in episodes])
@ -2600,7 +2599,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
log('QUEUE RUNNER: %s', url, sender=self)
try:
# The URL is valid and does not exist already - subscribe!
channel = PodcastChannel.load(self.db, url=url, create=True, \
channel = Model.load_podcast(self.db, url=url, create=True, \
authentication_tokens=auth_tokens.get(url, None), \
max_episodes=self.config.max_episodes_per_feed, \
mimetype_prefs=self.config.mimetype_prefs)
@ -2711,7 +2710,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
self.db.commit()
self.updating_feed_cache = False
self.channels = PodcastChannel.load_from_db(self.db)
self.channels = Model.get_podcasts(self.db)
# Process received episode actions for all updated URLs
self.process_received_episode_actions(updated_urls)
@ -2896,7 +2895,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
return
if not force_update:
self.channels = PodcastChannel.load_from_db(self.db)
self.channels = Model.get_podcasts(self.db)
self.channel_list_changed = True
self.update_podcast_list_model(select_url=select_url_afterwards)
return

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@ class qtPodder(QApplication):
def __init__(self, args, config, db):
QApplication.__init__(self, args)
podcasts = model.PodcastChannel.load_from_db(db)
podcasts = model.Model.get_podcasts(db)
self.podcast_list = gPodderListView(self.on_podcast_selected)
self.podcast_list.setModel(gPodderListModel(podcasts))