annotate Feed.py @ 32:500ba01e7f7a

TODO items
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 30 Apr 2010 06:02:06 +0200
parents 5bb57caa8f66
children aaec263f07ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
1
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
2 import FeedEntry
2
8a624ee48a74 First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3
8a624ee48a74 First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 class Feed(object):
16
3ffecc709da9 move fetch logic into Feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 7
diff changeset
5 @staticmethod
3ffecc709da9 move fetch logic into Feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 7
diff changeset
6 def all(session):
3ffecc709da9 move fetch logic into Feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 7
diff changeset
7 return session.query(Feed).order_by(Feed.title).all()
3ffecc709da9 move fetch logic into Feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 7
diff changeset
8
7
215c34f61e95 Feed.url -> Feed.rss_url
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 4
diff changeset
9 def __init__(self, title, rss_url):
215c34f61e95 Feed.url -> Feed.rss_url
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 4
diff changeset
10 self.title = title
215c34f61e95 Feed.url -> Feed.rss_url
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 4
diff changeset
11 self.rss_url = rss_url
2
8a624ee48a74 First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12
8a624ee48a74 First skeleton for sqlalchemy: define the mapping and create the first feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 def __repr__(self):
7
215c34f61e95 Feed.url -> Feed.rss_url
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 4
diff changeset
14 return "<Feed (%d) %s>" % (self.pk, self.title)
17
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
15
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
16 def userPresentableString(self):
5fda8bd94fa8 make the model used to display feeds generic (so it can be used to display FeedEntries, too)
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 16
diff changeset
17 return self.title
31
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
18
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
19 def entriesSortedByUpdateDate(self):
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
20 sortedEntries = list(self.entries)
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
21 sortedEntries.sort(FeedEntry.compareByUpdateDate)
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 17
diff changeset
22 return sortedEntries