rss/views.py @ a3380ed37242

Cleanup Tuesdays - Removed the photoblog, removed the silly ProjectPhoto thing too.
author Steve Losh <steve@stevelosh.com>
date Tue, 24 Mar 2009 17:57:23 -0400
parents e1000c7e0906
children (none)
from stevelosh.deploy import FEEDER_PASSWORD
import urllib2
import django.contrib.syndication.views

def feeds(request, url, feed_dict):
    headers = {'HTTP_HOST':'Host',
               'HTTP_USER_AGENT':'User-Agent',
               'HTTP_ACCEPT_ENCODING':'Accept-Encoding',
               'HTTP_ACCEPT_LANGUAGE':'Accept-Language',
               'HTTP_REFERER':'Referer',
               'HTTP_COOKIE':'Cookies'}
    
    feed_name = [p.capitalize() for p in url.split('/') if p.strip() != ''][-1]
    
    # Call into BirdFeeder with the request headers.
    o = urllib2.build_opener()
    o.addheaders = [ (headers[k], request.META.get(k, '')) 
                     for k in request.META.keys() if k in headers.keys()]
    f = o.open( "http://stevelosh.com/feeder/index.php?pw=%s&feed_name=%s" % 
                (FEEDER_PASSWORD, feed_name) )
    f.read()
    f.close()

    return django.contrib.syndication.views.feed(request, url=url, 
                                                 feed_dict=feed_dict)