Check server status before we check the contents of the feed
authorMagnus Hagander <magnus@hagander.net>
Sun, 6 Mar 2011 15:31:41 +0000 (16:31 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 6 Mar 2011 15:31:41 +0000 (16:31 +0100)
By checking the contents first, we'd get an exception before
we got to the status check, and thus generate an incorrect message

hamnadmin/register/views.py

index 6ad42e0ad8dac01cf99ce35932892187fc45f81d..1c00e507923c8b11d2446d5c25c83391a8ee14c3 100644 (file)
@@ -70,6 +70,8 @@ def new(request):
        try:
                feed = feedparser.parse(feedurl)
                status = feed.status
+               if not status == 200:
+                       raise pExcept('Attempt to download blog feed returned status %s.' % (status))
                lnk = feed.feed.link
                l = len(feed.entries)
                if l < 1:
@@ -78,8 +80,6 @@ def new(request):
                raise
        except Exception, e:
                raise pExcept('Failed to download blog feed: %s' % e)
-       if not status == 200:
-               raise pExcept('Attempt to download blog feed returned status %s.' % (status))
        
        if not settings.NOTIFYADDR:
                raise pExcept('Notify address not specified, cannot complete')