On Jan 3, 2008 11:08 PM, Titus Brown &lt;<a href="mailto:titus@caltech.edu">titus@caltech.edu</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Jan 03, 2008 at 03:54:35PM -0600, Ken Kuhlman wrote:<br>-&gt; I&#39;ve been trying to do a better job of testing my (turbogears) web apps<br><div class="Ih2E3d">-&gt; lately, and am trying to decide if I should be using twill or 
paste.fixture.<br>-&gt; I like a lot of things about twill, but one of the key strengths of paste<br>-&gt; (IMHO) is that it&#39;s &quot;in process&quot; testing feature includes the ability to<br>-&gt; dump the wsgi environment (unlike wsgi_intercept, which otherwise is a very
<br>-&gt; nice hack). &nbsp; Access to the environ is very handy [1] when you&#39;re doing MVC<br>-&gt; work &amp; trying to seperate what the controller&#39;s doing from what the rendered<br>-&gt; result looks like.<br>-&gt; Anyway, code speaks louder than words, so I&#39;ve included an example of what
<br>-&gt; I&#39;d like to see, and a patch to twill to make it work. &nbsp; I&#39;d be interested<br>-&gt; to know if you all think I&#39;m on the right track or if I&#39;m all wet. &nbsp;I&#39;m a<br>-&gt; twill &amp; wsgi n00b, so my apologies if I&#39;ve missed anything obvious.
<br><br></div>Hey Ken! &nbsp;Good idea, and one that I think can be generalized nicely...<br>which is why I want to think about it a bit more before committing to<br>any one direction. &nbsp;We should include Kumar, too, because he&#39;s taken
<br>over wsgi_intercept - Kumar, are you on this list?<br><br>First, I don&#39;t want to include a default command that deals with WSGI,<br>because most people probably won&#39;t know what it is or use it. &nbsp;We could<br>still create an extension module, but there are some other questions...
<br></blockquote><div><br>Cool.. I figured this would be a first attempt.&nbsp;&nbsp; Extension module it is. <br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>For example, you may want to have multiple WSGI apps in play, in which<br>case your global environ hack would cause problems. &nbsp;(This is why<br>_wsgi_intercept, which contains the apps, is the only global one.)<br><br>
And why not use middleware instead of a solid hook? &nbsp;Something like<br>this:<br><br>--<br># install &#39;simple_app&#39; with an environment printer under &#39;foo_name&#39;<br>app_fn = lambda: twill.wsgi.env_printer(&#39;foo_name&#39;, simple_app)
<br>twill.add_wsgi_intercept(&#39;localhost&#39;, 8001, lambda: app_fn)<br>--<br></blockquote><div><br>I was thinking that the global hack would only impact multiple wsgi_intercept calls, which would be less of a problem.&nbsp; I believe you when you say it&#39;s more than that, though, and I agree that doing it as middleware is less hackish. 
<br><br>I&#39;ll need to play around with it a bit though, because right now the double lambdas around app_fn are over my head.&nbsp;&nbsp; Should the middleware be added to wsgi_intercept so that other potential users can use it?<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Then we could have twill_wsgi functions, e.g.<br><br>--<br>val = twill_wsgi.print_environ(&#39;foo_name&#39;, &#39;env_variable_to_print&#39;)
<br>--<br><br>or twill script,<br><br>&gt;&gt; extend_with twill_wsgi<br>&gt;&gt; print_environ foo_name env_variable_to_print<br><br>thoughts?<br><font color="#888888"></font></blockquote><div><br>Yeah, that looks solid. &nbsp; I&#39;ll play around with it this weekend and see what I can come up with. 
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888">--titus<br></font></blockquote></div><br>Thanks for the reply!
<br>-Ken<br><br>