[twill] Access to the WSGI environment with wsgi_intercept
ianb at colorstudy.com
Mon Jan 7 09:30:44 PST 2008
Ken Kuhlman wrote:
> Well, I think I've succeeded in writing the world's most trivial
> middleware. :-) Once I got into this, I realized that I didn't want
> to re-issue a request just to dump the environ. Instead, I save off the
> environ on every request and access it as needed.
> One issue that comes up with this approach is EnvPrinter will have to be
> the last middleware in the stack or the environ won't be complete; the
> test author will just have to know this requirement. Of course, it's
> possible someone might want to dump the environ from the middle of the
> stack, too, so maybe this is more of a feature than a bug.
Another technique you might want to support is what
paste.fixture.TestApp (and webtest.TestApp) do, which is put a
dictionary in environ['paste.testing_variables'], and you can write to
that dictionary to explicitly expose values to the tests. This is used
for example to expose the raw values you pass to the template in Pylons.
Don't let the "paste" in 'paste.testing_variables' scare you off; it's
just a string, and since it got implemented in Paste first that's the
namespace that got used (xmlns-like).
Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org
More information about the twill