Hello,<div>    I&#39;ve been using Twisted on and off now for about four years, mostly for personal projects and some R&amp;D work for a few startups.  I&#39;ve been a semi-professional Python programmer for four years as well, unfortunately it only makes up about 15-20% of my annual income.  That said for Python web development I was rather fond of Pylons and then moved from it to CherryPy.  With those two frameworks influencing me, I wanted a similar interface for Twisted.Web and after a lot of trial and error I&#39;ve got an alpha version proof of concept that is simply called txWeb.  <a href="https://github.com/devdave/txWeb">https://github.com/devdave/txWeb</a></div>
<div><br></div><div>Very briefly using an example from JCalderone&#39;s wonderful collection of tutorial/examples:</div><div><a href="http://jcalderone.livejournal.com/49707.html">http://jcalderone.livejournal.com/49707.html</a></div>
<div><br></div><div>Instead of doing </div><div><br></div>from twisted.web.server import Site<br>from twisted.web.resource import Resource<br>from twisted.internet import reactor<div><br><div>class FormPage(Resource):</div>
<div>       def render_GET(self, request)</div><div>            return &#39;&lt;html&gt;&lt;body&gt;&lt;form method=&quot;POST&quot;&gt;&lt;input name=&quot;the-field&quot; type=&quot;text&quot; /&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;&#39;</div>
<br>       def render_POST(self, request):<br>             return &#39;&lt;html&gt;&lt;body&gt;You submitted: %s&lt;/body&gt;&lt;/html&gt;&#39; % (cgi.escape(request.args[&quot;the-field&quot;][0]),)<div><span class="Apple-style-span" style="font-family: monospace; font-size: 12px; line-height: 13px; white-space: pre; background-color: rgb(255, 255, 255); "><br>
</span></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: 13px; white-space: pre;"><br></span></font></div><div>root = Resource()</div><div>root.putChild(&quot;form&quot;, FormPage() )</div>
factory = Site(root)<br>reactor.listenTCP(8880, factory)<br>reactor.run()<div><br></div><div><br></div></div><div>the alternative would be:  </div><div><br></div><div><div>from txweb.core import Site</div><div>#from twisted.web.resource import Resource</div>
<div>from twisted.internet import reactor</div><div>import cgi</div><div><br></div><div>class Root(object):</div><div>    </div><div>    </div><div>    </div><div>    def form(self, request):</div><div>        return &#39;&lt;html&gt;&lt;body&gt;&lt;form action=&quot;/process&quot; method=&quot;POST&quot;&gt;&lt;input name=&quot;the-field&quot; type=&quot;text&quot; /&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;&#39;                </div>
<div>    form.exposed = True</div><div>    </div><div>    index = form</div><div>        </div><div>    def process(self, request):</div><div>        return &#39;&lt;html&gt;&lt;body&gt;You submitted: %s&lt;/body&gt;&lt;/html&gt;&#39; % (cgi.escape(request.args[&quot;the-field&quot;][0]),)</div>
<div>    process.exposed = True</div><div><br></div><div>reactor.listenTCP(8880, Site(Root()))</div><div>reactor.run()</div></div><div><br></div><div><br></div><div>A cleaner version of the example above is available @ <a href="https://gist.github.com/1257921">https://gist.github.com/1257921</a></div>
<div><br></div><div>My goals with txWeb isn&#39;t to replace the twisted.web Resource mechanism but instead provide an alternative that friendlier towards those with experience with Pylons/CherryPy/Django while avoiding duplicating anything that twisted.web provides ( ex. File resources can be class attributes )</div>
<div><br></div><div><br></div><div>That all said, any critique&#39;s or constructive input is very much welcome.   So far I know the unit-tests need to be cleaned up, inside the routing routeRequest method the wrapper OneTimeResource is created, used, and thrown away which is somewhat wasteful as its a mostly stateless object.  But I&#39;m not sure if I&#39;m missing something big that could make txWeb unviable for production use without some sort of major refactoring.</div>
<div><br></div><div><br></div><div>Thanks,</div><div>    David W.</div><div><br></div><div><br></div><div><br></div><div><br></div>