view backend/AbstractBackend.py @ 213:524cbf9e413c

use correct TODO tags so they show up in the tasks view in Eclipse
author dirk
date Wed, 28 Nov 2012 01:53:29 +0100
parents f74fe7cb5091
children bb3c851b18b1
line wrap: on
line source


from datetime import datetime, timedelta

def calculateExpireDate(preferences):
        now = datetime.now()
        daysToKeepFeedEntries = preferences.daysToKeepFeedEntries()
        delta = timedelta(days=daysToKeepFeedEntries)
        return now - delta

class AbstractBackend(object):
    def __init__(self):
        self.feeds = []
        self.selectedFeed = None
        self.feedEntries = None
        self.selectedFeedEntry = None

    def dispose(self):
        pass

    #
    # handling of feeds
    #

    def selectFeed(self, index):
        self.selectedFeed = self.feeds[index]
        self.feedEntries = None
        return self.selectedFeed

    def entriesForSelectedFeed(self):
        if self.feedEntries is None:
            hideReadEntries = self.preferences().hideReadFeedEntries()
            self.feedEntries = self._retrieveEntriesForSelectedFeed(hideReadEntries)
        return self.feedEntries

    def _calculateExpireDate(self):
        return calculateExpireDate(self.preferences())

    #
    # handling of the selected feed entry
    #

    def selectFeedEntry(self, index):
        self.selectedFeedEntry = self.feedEntries[index]
        self._markSelectedFeedEntryRead()
        return self.selectedFeedEntry