Ticket #2402: middleware.py

File middleware.py, 1.1 KB (added by dev@…, 18 years ago)
Line 
1class Djazzify(object):
2 """
3 Adds a Django header to requests.
4 """
5 def process_response(self, request, response):
6 # thought about including version info, but decided it was better not to leak this
7 response['X-Djazzified-By'] = "Django"
8 return response
9
10class NowPlaying(object):
11 """
12 Adds a Now-Playing song from a list of Django songs.
13 """
14 def process_response(self, request, response):
15
16 # do this here so that people only using Djazzify don't get this unnecessarily.
17 from random import sample
18
19 # list of tunes from http://www.djangomusic.com/item_music.asp?id=R+++329540&dt=2&cid=&sid=&mediatype=
20 tunes = [ "St. Louis Blues", "After You've Gone"
21 "Nagasaki", "Swing Guitars", "Exactly Like You", "Solitude",
22 "You're Driving Me Crazy", "Ain't Misbehavin'", "Rose Room",
23 "Chicago", "Minor Swing", "Swingin' with Django", "Lambeth Walk",
24 "Swing '39", "Japanese Sandman", "Nuages", ]
25
26 response['X-Now-Playing'] = sample( tunes, 1 )[ 0 ]
27 return response
Back to Top