view FeedEntry.py @ 59:daa2731967fe

Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 23 Jul 2010 17:29:22 +0200
parents f371d02fa09d
children abc0516a1c0c
line wrap: on
line source


from datetime import datetime

def compareByUpdateDate(first, second):
    return cmp(first.updated, second.updated)

class FeedEntry(object):
    @staticmethod
    def findById(id, session):
        result = session.query(FeedEntry).filter(FeedEntry.id == id)
        return result.first()

    def __init__(self):
        self.create_timestamp = datetime.now()
        self.read = 0

    def __repr__(self):
        return "<FeedEntry (%d) %s>" % (self.pk, self.title)

    def userPresentableString(self):
        return self.title
    
    def toggleRead(self):
        if self.read:
            self.markUnread()
        else:
            self.markRead()
            
    def markRead(self):
        self.read = 1

    def markUnread(self):
        self.read = 0