Mercurial > hg > Feedworm
view Feed.py @ 87:b8bfd1bd6c55
use a proxy if one is configured. TODO: GUI for configuring the proxy server
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 17 Nov 2010 21:22:31 +0100 |
parents | d292ab61ed6f |
children | e59d722439b5 |
line wrap: on
line source
from datetime import datetime, timedelta import FeedEntry class Feed(object): @staticmethod def all(session): return session.query(Feed).order_by(Feed.title).all() def __init__(self, title, rss_url): self.title = title self.rss_url = rss_url # default: update every 60 minutes self.update_interval = 60 self.incrementNextUpdateDate() self.auto_load_entry_link = False self.always_open_in_browser = False def __repr__(self): return "<Feed (%d) %s>" % (self.pk, self.title) def userPresentableString(self): return self.title def entriesSortedByUpdateDate(self, hideReadEntries=False): sortedEntries = list(self.entries) sortedEntries.sort(FeedEntry.compareByUpdateDate) if hideReadEntries: return self._filterReadEntries(sortedEntries) return sortedEntries def _filterReadEntries(self, entries): retValue = [] for entry in entries: if not entry.read: retValue.append(entry) return retValue def incrementNextUpdateDate(self): delta = timedelta(minutes=self.update_interval) self.next_update = datetime.now() + delta def markAllEntriesRead(self): for entry in self.entries: entry.markRead()