Login

feedburner middleware

Author:
V
Posted:
September 23, 2008
Language:
Python
Version:
1.0
Tags:
middleware feedburner
Score:
3 (after 3 ratings)

This middleware redirects the request for yoursite.com/feed/whatever/onefeed to your feedburner onefeed feed.

Having FEEDBURNER = ('SomeName', ('blog', 'comments', 'tag1')) will use the feedburner feeds at http://feedproxy.google.com/SomeName/blog http://feedproxy.google.com/SomeName/comments http://feedproxy.google.com/SomeName/tag/tag1

you can add more tags, or even intersection and union of them the same way

(thanks to piranha for the idea of a middleware)

Update: now it works for tags as well

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.http import HttpResponseRedirect
import settings


class FeedburnerMiddleware(object):
    '''
    Redirect the user to a feedburner feed for basic feeds
    '''
    def process_request(self, request):
        r = request.path.split('/')
        if not settings.FEEDBURNER or\
            not r[1] == 'feeds' or \
            not r[-2] in settings.FEEDBURNER[1]:
            return None
        
        if request.META['HTTP_USER_AGENT'].startswith('FeedBurner'):
            return None
        else:
            return HttpResponseRedirect('/'.join((
                'http://feedproxy.google.com', 
                settings.FEEDBURNER[0],
                '/'.join(r[3:-1]))
                ))

More like this

  1. Display arbitrary models by bjornkri 6 years, 10 months ago
  2. LinkShare Pixel Tracking template tag for Satchmo by maxk 4 years, 4 months ago
  3. RSS feed with content:encoded elements by philgyford 4 years, 8 months ago
  4. Row-Level, URL-based permissions for FlatPages by bradmontgomery 5 years, 11 months ago
  5. Unobtrusive comment moderation by ubernostrum 8 years, 2 months ago

Comments

adoleo (on September 23, 2008):

This is great! Thank you for sharing it!

#

Please login first before commenting.