Ian Bicking: the old part of his blog

Re: It's Not Another Damn Framework

Ian, I think finally get it. :-)

Paste is not a 'framework framework' and it's 'middleware'... it's 'filters'! <cue sound of mind going 'click!'> My brain only 'gets' things when I can see a practical use for it. :-)

I've been playing around with CherryPy's filters and that description makes sense. You can write a function or class method once, and use filters to repurpose the functions/methods for different contexts (HTTP/HTML vs XML-RPC) without touching your original function/method definitions.

Perhaps, you could also call them "wrappers" or "envelopes". And I'm sure Martin Fowler has a pattern with a really complicated name for it, too. :-) But filters fits my brain the best.

With filters (at least as I understand it in CherryPy), you can do the following:

  1. Write a function called helloWorld() that simply returns the string "Hello, world!"

  2. Now go write a filter that can accept XML-RPC commands and dispatch them to any function, and take any return values and return them as XML-RPC. (CherryPy already provides this for XML-RPC).

  3. Do the same for SOAP, YAML, XML, JSON, GZIP compression, conversion to PDF, or whatever

  4. Setup up your config so various URLS can call your helloWorld using a filter of your choosing:

    http://localhost/soap/helloWorld -> callable via SOAP client library, calls hellWorld, and returns "hello world" as a SOAP response. http://localhost/xmlrpc/helloWorld -> same thing as SOAP, but for for XML-RPC http://localhst/yaml/helloWorld -> etc, etc.

Voila! Paste now makes sense to me. I can see how this would be useful, too... I don't think Django does Webservices (XML-RPC, SOAP, REST), yet. (I could be wrong, but I haven't seen any mention of it, yet.) If there was a "standard" implementation of "filters" that other frameworks could use... then Django could benefit from this work for free without having to reimplement CherryPy's filters.

Now that I've written all of this... Do I understand WSGI and Paste correctly? Now, that I think about it... you also just reinvented unix pipes, but for the web. And I think Apache 2 even implements the same thing, too. (http://www.projectcomputing.com/resources/apacheFilterFAQ/) Correct?

Comment on It's Not Another Damn Framework
by Jason Huggins