summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-10-07 19:16:40 -0500
committerDan McGee <dan@archlinux.org>2010-10-07 19:16:40 -0500
commitcf7bf2de294a0e7be37f03935c0a292d60ed1829 (patch)
tree873d89f873460b72387ec84f4ff2b1b7503a9de6
parent82f3b02f602b8244047ab12f38dadc42f416bd2d (diff)
Factor out common last modified code for news feed
This will set up retrieving this value from memcached as well as some other changes to come. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--feeds.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/feeds.py b/feeds.py
index ac85c72b..c46a8be3 100644
--- a/feeds.py
+++ b/feeds.py
@@ -78,18 +78,23 @@ class PackageFeed(Feed):
return (item.repo.name, item.arch.name)
-def news_etag(request, *args, **kwargs):
- latest = News.objects.latest('last_modified')
- if latest:
- return md5_constructor(str(latest.last_modified)).hexdigest()
+def retrieve_news_latest():
+ try:
+ latest = News.objects.values('last_modified').latest('last_modified')
+ return latest['last_modified']
+ except News.DoesNotExist:
+ pass
return None
-def news_last_modified(request):
- latest = News.objects.latest('last_modified')
+def news_etag(request, *args, **kwargs):
+ latest = retrieve_news_latest()
if latest:
- return latest.last_modified
+ return md5_constructor(str(latest)).hexdigest()
return None
+def news_last_modified(request, *args, **kwargs):
+ return retrieve_news_latest()
+
class NewsFeed(Feed):
title = 'Arch Linux: Recent news updates'
link = '/news/'