After looking through the many useful and shiny Python frameworks, I find none of them get close to what I need or provide way more than my needs. I'm looking to put something together myself; could define it as a framework, but not full-stack. However, I can't find online what the Python community sees as the correct/standard way to manage WSGI middleware in an application.
I'm not looking for framework suggestions, unless its to provide an example of ways to manage WSGI middleware. Nor am I looking for information on how to get a webserver to talk to python -- that bit I understand.
Rather, I'm looking for advice on how one tells python what components/middleware to put into the stack, and in which order. For instance, if I wanted to use:
Spawning-->memento-->AuthKit-->(?)-->MyApp
how would I get those components into the right order, and how would I configure an additional item (say Routes) before MyApp
?
So; Can you advise on the common/correct/standard way of managing what middleware is included in a WSGI stack for a Python application?
Edit
Thanks to Michael Dillon for recommending A Do-It-Yourself Framework, which helps highlight my problem. The middleware section of that document states that one should wrap middleware A in middleware B, B in C, and so-on:
app = ObjectPublisher(Root())
wrapped_app = AuthMiddleware(app)
from paste.evalexception import EvalException
exc_wrapped_app = EvalException(wrapped_app)
Which shows how to do it in a very simple way. I understand how this works, however it seems too simple when working with a number of middleware packages.
Is there a better way to manage how these middleware components are added to the stack? Maybe a common design pattern which reads from a config file?