summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ee856f62..2e9b349b 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 e7e47c53..b7cb19f4 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.