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
- Class Feeds DRY TemplateTag by gmandx 3 years, 1 month ago
- TaggedManager and TaggedQuerySet with chainable tagged() methods implemented with django-tagging by fish2000 3 years, 3 months ago
- Display arbitrary models by bjornkri 4 years, 11 months ago
- View to retrieve objects meeting a complex tag query by nathangeffen 2 years, 6 months ago
- Template tag to clear cached template fragment by joao.coelho 3 years, 7 months ago
Comments
This is great! Thank you for sharing it!
#