[Twisted-web] Hello introductions to me and one of my pet projects

Jacek Furmankiewicz jacek99 at gmail.com
Sun Oct 2 18:53:56 EDT 2011


Hi David, I've been trying to the same thing :-)
although keeping the Resource part, which I like (especially because it
automatically handles routing to children),
amongst many things.

Hope you'll like it too:
https://github.com/jacek99/corepost

Cheers,
Jacek

On Sun, Oct 2, 2011 at 4:49 PM, David J W <twistedwebmailinglist at ominian.net
> wrote:

> Hello,
>     I've been using Twisted on and off now for about four years, mostly for
> personal projects and some R&D work for a few startups.  I'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've got an alpha version
> proof of concept that is simply called txWeb.
> https://github.com/devdave/txWeb
>
> Very briefly using an example from JCalderone's wonderful collection of
> tutorial/examples:
> http://jcalderone.livejournal.com/49707.html
>
> Instead of doing
>
> from twisted.web.server import Site
> from twisted.web.resource import Resource
> from twisted.internet import reactor
>
> class FormPage(Resource):
>        def render_GET(self, request)
>             return '<html><body><form method="POST"><input name="the-field"
> type="text" /></form></body></html>'
>
>        def render_POST(self, request):
>              return '<html><body>You submitted: %s</body></html>' %
> (cgi.escape(request.args["the-field"][0]),)
>
>
> root = Resource()
> root.putChild("form", FormPage() )
> factory = Site(root)
> reactor.listenTCP(8880, factory)
> reactor.run()
>
>
> the alternative would be:
>
> from txweb.core import Site
> #from twisted.web.resource import Resource
> from twisted.internet import reactor
> import cgi
>
> class Root(object):
>
>
>
>     def form(self, request):
>         return '<html><body><form action="/process" method="POST"><input
> name="the-field" type="text" /></form></body></html>'
>     form.exposed = True
>
>     index = form
>
>     def process(self, request):
>         return '<html><body>You submitted: %s</body></html>' %
> (cgi.escape(request.args["the-field"][0]),)
>     process.exposed = True
>
> reactor.listenTCP(8880, Site(Root()))
> reactor.run()
>
>
> A cleaner version of the example above is available @
> https://gist.github.com/1257921
>
> My goals with txWeb isn'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 )
>
>
> That all said, any critique'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'm
> not sure if I'm missing something big that could make txWeb unviable for
> production use without some sort of major refactoring.
>
>
> Thanks,
>     David W.
>
>
>
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20111002/46b06a63/attachment.htm 


More information about the Twisted-web mailing list