Commits

Matt Croydon committed 0c88959

Fixed IndexError raised in production. Originally approached this as two try/except blocks for the date and main item but think this is cleaner. I'm still on the fence though.

Comments (0)

Files changed (2)

+diff -r a47ea387c393 template_utils/templatetags/feeds.py
+--- a/template_utils/templatetags/feeds.py	Sat Sep 27 07:59:57 2008 -0500
++++ b/template_utils/templatetags/feeds.py	Fri Dec 18 17:10:08 2009 -0600
+@@ -27,12 +27,15 @@
+         items = []
+         num_items = int(self.num_items) or len(feed['entries'])
+         for i in range(num_items):
+-            pub_date = feed['entries'][i].updated_parsed
+-            published = datetime.date(pub_date[0], pub_date[1], pub_date[2])
+-            items.append({ 'title': feed['entries'][i].title,
+-                           'summary': feed['entries'][i].summary,
+-                           'link': feed['entries'][i].link,
+-                           'date': published })
++            try:
++                pub_date = feed['entries'][i].updated_parsed
++                published = datetime.date(pub_date[0], pub_date[1], pub_date[2])
++                items.append({ 'title': feed['entries'][i].title,
++                               'summary': feed['entries'][i].summary,
++                               'link': feed['entries'][i].link,
++                               'date': published })
++            except IndexError:
++                pass
+         return render_to_string(self.template_name, { 'items': items,
+                                                       'feed': feed })
+ 
+feeds-indexerror
 # Placed by Bitbucket
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.