view backend/couchdb/FeedEntry.py @ 158:e8bb107a74e1

all preferences are stored in a single JSON document in the couchdb backend. PreferencesDialog converts QString to a proper Python datatybe before sending it to the backend.
author dirk
date Mon, 29 Aug 2011 02:33:51 +0200
parents a05719a6175e
children e284a37df1d9
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:
#            row = iter(result).next()
#            return FeedEntry(row)
#        except StopIteration:
#            return None
        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)