working on refactoring wsgi and django middleware