view backend/sqlalchemy/FeedEntry.py @ 215:b7caf487bc54

run make prior to starting the worm
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 13 May 2013 17:35:11 +0200
parents 04a730f9d07d
children bb3c851b18b1
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()

    @staticmethod
    def create(entry):
        new = FeedEntry()
        new.id = entry.id
        new.link = entry.link
        new.title = entry.title
        new.updated = entry.updated_parsed
        new.summary = entry.summary
        return new

    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