view backend/couchdb/FeedEntry.py @ 171:27be2a5f9c10

use the new ListDateTimeField in FeedEntries to store their creation date
author dirk
date Fri, 09 Sep 2011 16:34:02 +0200
parents 91a24f499318
children d0ced79b5030
line wrap: on
line source


from backend.couchdb.ListDateTimeField import ListDateTimeField
from couchdb.mapping import BooleanField, DateTimeField, Document, TextField
from datetime import datetime
import CouchDb

class FeedEntry(Document):
    doctype = TextField(default="feedEntry")
    create_timestamp = ListDateTimeField(default=datetime.now())
    read = BooleanField(default=False)
    link = TextField()
    title = TextField()
    summary = TextField()
    updated = DateTimeField()
    feed = TextField()

    @staticmethod
    def findByLink(link, database):
        result = FeedEntry.view(database, CouchDb.feedEntryByLink(), key=link)
        try:
            return iter(result).next()
        except StopIteration:
            return None

    def markRead(self, database):
        self.read = True
        self.store(database)

    def toggleRead(self, database):
        if self.read:
            self.read = False
        else:
            self.read = True
        self.store(database)