comparison backend/sqlalchemy/FeedEntry.py @ 119:04a730f9d07d backend

move all sqlalchemy related classes to the respective sub-package. use a backend to abstract from access to the data
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sun, 21 Aug 2011 03:55:16 +0200
parents FeedEntry.py@abc0516a1c0c
children bb3c851b18b1
comparison
equal deleted inserted replaced
118:0e73adb2dec4 119:04a730f9d07d
1
2 from datetime import datetime
3
4 def compareByUpdateDate(first, second):
5 return cmp(first.updated, second.updated)
6
7 class FeedEntry(object):
8 @staticmethod
9 def findById(id, session):
10 result = session.query(FeedEntry).filter(FeedEntry.id == id)
11 return result.first()
12
13 @staticmethod
14 def create(entry):
15 new = FeedEntry()
16 new.id = entry.id
17 new.link = entry.link
18 new.title = entry.title
19 new.updated = entry.updated_parsed
20 new.summary = entry.summary
21 return new
22
23 def __init__(self):
24 self.create_timestamp = datetime.now()
25 self.read = 0
26
27 def __repr__(self):
28 return "<FeedEntry (%d) %s>" % (self.pk, self.title)
29
30 def userPresentableString(self):
31 return self.title
32
33 def toggleRead(self):
34 if self.read:
35 self.markUnread()
36 else:
37 self.markRead()
38
39 def markRead(self):
40 self.read = 1
41
42 def markUnread(self):
43 self.read = 0