Code listings form the excellent book of Harry Percival: Test-Driven Web Development with Python