Mercurial > hg > Feedworm
view backend/couchdb/FeedEntry.py @ 169:91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
author | dirk |
---|---|
date | Fri, 09 Sep 2011 14:52:54 +0200 |
parents | e284a37df1d9 |
children | 27be2a5f9c10 |
line wrap: on
line source
from couchdb.mapping import BooleanField, DateTimeField, Document, TextField from datetime import datetime import CouchDb 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, 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)