Add support for middleware to extensions.

This change adds the ability for extensions to add middleware. This is done by
setting the 'middleware' attribute on the extension's class to be a list of
class names. These are then injected into Django's list of middleware according
to the dependency structure of the extensions.

Testing done: All unit tests pass
Reviewed at https://reviews.reviewboard.org/r/4530/