AlphacrucisCollege / django-template-utils

Fork of (abandoned?) package used in ac.edu.au. Exported via GoogleCodeExport.
https://bitbucket.org/ubernostrum/django-template-utils
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

include_feed raise an eception if RSS feed is unreachable #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Pass include_feed a non existing URL as first parameter (URL of the feed
to parse)

What is the expected output? What do you see instead?
I would expect the template to use for rendering the results into HTML
simply gets an empty "items" value so we can handle cases when RSS feed is
unreachable:

{% if items %}
 ... render RSS feed ...
{% else %}
 --- a fallback in case feed is unreachable ...
{% endif %}

Instead, an exception is raised:
Caught an exception while rendering: list index out of range

Original Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/django/template/debug.py",
line 71, in render_node
    result = node.render(context)
  File "/usr/home/django/django_apps/template_utils/templatetags/feeds.py",
line 30, in render
    pub_date = feed['entries'][i].updated_parsed
IndexError: list index out of range

What version of the product are you using? On what operating system?
Revision 109 on FreeBSD 7.0-RELEASE
Django is updated from SVN on 2008 Aug 30

Please provide any additional information below.
Maybe I'm doing something wrong, but since I include an RSS feed with this
library in every page of my site, if the feed is unreachable, every page of
my site will raise an exception. 

The attached patch works for me; it IS NOT A SOLUTION but simply a dirty
workaround to help better describe the issue. 

Original issue reported on code.google.com by a...@netsail.it on 1 Sep 2008 at 2:10

Attachments:

GoogleCodeExporter commented 8 years ago
FYI: I had this exact same problem.

Original comment by ben.welsh@gmail.com on 30 May 2009 at 1:02