Leslie Orchard
just wrote a WSGI middleware for interpreting XSLT. This is cool,
because it's one of those things I've thought is perfect for WSGI, and
I even mentioned it
yesterday. This means any WSGI application can output XML and have it
transformed by an XSLT stylesheet, without any awareness on the part
of the application.
It's also great to see someone catch on to what WSGI is about. I'm
afraid I haven't been that successful explaining it. But maybe I
should use his endorsement of the architecture: "it's not another damn
framework."
And that's exactly the kind of architectural principle that made me
write Paste. I've been describing it as a "framework framework",
which is awful -- 2x the badness! Really, it's a collection of
exactly the sort of thing that Leslie wrote -- simple, decoupled
bits of middleware. Oh, damn, there's that "middleware" word again,
which is also bad. Simple, decoupled filters. Everything else in
Paste is the crap I had to put in to get it to work together. Stuff
like configuration. This isn't what makes me excited -- it's just
the pain in the ass that someone needs to do, and at least in the
context of WSGI no one else is doing it.
What makes me excited is bits of code like this. This is 55 (logical)
lines of code that implement XSLT in front of any Python application
that produces XML (and if someone writes a WSGI proxy app, in front of any
application in any language). 55 lines -- that is what excites me.
So, like, if you have a web app that follows the WSGI spec, it can be
swallowed up by filtering apps. The filtered apps can have any
number of mammoth Python web frameworks powering them, and the
filters can be as complex or simple as you want. Hell, build a web
framework entirely out of composed filters! [emphasis his]
Which is exactly what I did with Paste's Webware interface, and later
Wareweb -- I
moved everything I could into middleware, and built the shell of a
framework around it. And it works -- the core of paste.webkit is
776 lines of code, and the code it replaces is 6313 lines of code.
That 700ish lines of code doesn't provide all the functionality of the
original 6000ish lines of code; but it builds a Webwarish thing on top
of generic libraries. For both of them I don't count the 600 lines in
the standard library's cgi module either, or the 50,000+ lines in
the standard library as a whole; so I think there is a fair comparison.
If you refactored a framework like CherryPy to use WSGI middleware, I think you'd see the
same kind of results.
The point of Paste is that you shouldn't have to compromise between
simple and full-featured, or between abstract and convenient,
or general and concrete. Paste is WSGI. Paste is filters built
on filters. Paste is HTTP turned into Python dictionaries.
WSGI is working from where CGI left off.
It's the simplest thing that can work. It's not a framework.