view backend/couchdb/FeedEntry.py @ 165:a5bda54309ba

add a couchapp for easy/automated setup
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 29 Aug 2011 04:12:01 +0200
parents e284a37df1d9
children 91a24f499318
line wrap: on
line source


from couchdb.mapping import BooleanField, DateTimeField, Document, TextField
from datetime import datetime

class FeedEntry(Document):
    doctype = TextField(default="feedEntry")
    create_timestamp = DateTimeField(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, "feedtest/feedEntry_by_link", 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)