summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-05-20 20:21:59 +0200
committerDan McGee <dan@archlinux.org>2012-05-20 20:21:59 +0200
commitd685d51e8c80f29d4f14977a0d8088534e6626c4 (patch)
tree3f710fbf51e1a81e0a22c0da07480d09d68b3956
parenteef1ee7051093b9f6e74ab5669af8c57983872d9 (diff)
downloadarchweb-d685d51e8c80f29d4f14977a0d8088534e6626c4.tar.gz
archweb-d685d51e8c80f29d4f14977a0d8088534e6626c4.tar.xz
Ensure we use last_modified date from News in headers
We were actually using the postdate attribute rather than last_modified, which means any News objects that get edited would not trigger an update of the feed. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--feeds.py4
-rw-r--r--main/utils.py7
2 files changed, 6 insertions, 5 deletions
diff --git a/feeds.py b/feeds.py
index ee856f6..2e9b349 100644
--- a/feeds.py
+++ b/feeds.py
@@ -106,13 +106,13 @@ class PackageFeed(Feed):
def news_etag(request, *args, **kwargs):
- latest = retrieve_latest(News)
+ latest = retrieve_latest(News, 'last_modified')
if latest:
return hashlib.md5(str(latest)).hexdigest()
return None
def news_last_modified(request, *args, **kwargs):
- return retrieve_latest(News)
+ return retrieve_latest(News, 'last_modified')
class NewsFeed(Feed):
feed_type = GuidNotPermalinkFeed
diff --git a/main/utils.py b/main/utils.py
index e7e47c5..b7cb19f 100644
--- a/main/utils.py
+++ b/main/utils.py
@@ -72,7 +72,7 @@ def refresh_latest(**kwargs):
cache.set(cache_key, None, INVALIDATE_TIMEOUT)
-def retrieve_latest(sender):
+def retrieve_latest(sender, latest_by=None):
# we could break this down based on the request url, but it would probably
# cost us more in query time to do so.
cache_key = CACHE_LATEST_PREFIX + sender.__name__
@@ -80,8 +80,9 @@ def retrieve_latest(sender):
if latest:
return latest
try:
- latest_by = sender._meta.get_latest_by
- latest = sender.objects.values(latest_by).latest()[latest_by]
+ if latest_by is None:
+ latest_by = sender._meta.get_latest_by
+ latest = sender.objects.values(latest_by).latest(latest_by)[latest_by]
# Using add means "don't overwrite anything in there". What could be in
# there is an explicit None value that our refresh signal set, which
# means we want to avoid race condition possibilities for a bit.