# HG changeset patch # User Paul Boddie # Date 1367958671 -7200 # Node ID 958a436338dee1eabb4d03e993add16cd6cdaaae # Parent 96b9ac545802cd20c32710e056289b3195dc9cef Limit the total number of entries shown, not the number retrieved from each feed, since the sorting should take place on the entire dataset before a limit is applied. diff -r 96b9ac545802 -r 958a436338de macros/SharedContent.py --- a/macros/SharedContent.py Tue May 07 20:03:45 2013 +0200 +++ b/macros/SharedContent.py Tue May 07 22:31:11 2013 +0200 @@ -109,7 +109,6 @@ feed_type = None update = None - nentries = 0 events = xml.dom.pulldom.parse(feed) @@ -170,11 +169,9 @@ if feed_type == "rss" and tagname == "item" or \ feed_type == "atom" and tagname == "entry": - if nentries < max_entries: - feed_updates.append(update) + feed_updates.append(update) update = None - nentries += 1 finally: feed.close() @@ -209,6 +206,9 @@ show_content = show_content or False max_entries = max_entries or MAX_ENTRIES + # Retrieve updates from feeds, classifying them as missing or bad and + # excluding them if appropriate. + updates = [] feeds = [] missing = [] @@ -237,6 +237,10 @@ updates.sort() updates.reverse() + # Truncate the number of updates to the maximum number. + + updates = updates[:max_entries] + for update in updates: # Emit content where appropriate.