[Twisted-web] Web2 Script.py seems to be broken

Matt Goodall matt at pollenation.net
Wed Feb 8 08:43:57 MST 2006


Todd Thomas wrote:
> 
> 
> On 2/7/06, *James Y Knight* <foom at fuhm.net <mailto:foom at fuhm.net>> wrote:
> 
>     On Feb 7, 2006, at 4:09 AM, Todd Thomas wrote:
>     > I find them extemely handy personally, how else are you going add
>     > resources without resorting to restarting the server? But I guess
>     > depends on what you are using them for. I tend to use twisted more
>     > for testing and experimenting, simpler than installing apache.
>     > Unfortunately twisted-web doesnt have a wsgi implementation, I have
>     > been messing around with django a bit trying to see how modular the
>     > code is.
> 
>     You'll notice that I said I was open to them still being supported.
>     I'll take a submission of code + unit tests for it, or if not, will
>     get around to implementing it someday.
> 
>     I'll also note, it should be possible to use twisted.web.script from
>     within a twisted.web2 server, although you won't be able to use web2
>     Resources in the rpys loaded by the twisted.web.script loader. (The
>     compatibility only works one way -- you can use old resources inside
>     new ones, but not new ones inside old ones).
> 
>     I think you might have meant this but it wasn't entirely clear so
>     I'll also note that twisted.web2 does support wsgi.
> 
>     James
> 
>     _______________________________________________
>     Twisted-web mailing list
>     Twisted-web at twistedmatrix.com <mailto:Twisted-web at twistedmatrix.com>
>     http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>     <http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web>
> 
> It does support wsgi, I was playing around with it. I went back to
> twisted-web, I like its lower level approach. Using http.request
> directly vs. resources is nice since I can pretty much tell exactly what
> is going on. I love the fact that you can work at an extremely low level
> in twisted-web. I hope twisted-web2 doesn't get too high level.


WARNING: completely untested ideas ahead. I'm not a big web2 user (yet).


I doubt it's difficult to write a server.Site equivalent to plug an
alternative framework directly into web2's HTTP protocol support. IIRC,
HTTPFactory expects nothing more than something callable that takes a
bunch of args.

Also, a root Resource that calls out to an alternative framework should
be trivial to implement. See t.web2.iweb.IResource for details. You
don't even need to subclass resource.Resource.

Once your framework handling resource is called it should be able to do
just about anything it wants as long as its renderHTTP returns an
http.Response instance.


- Matt


-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.



More information about the Twisted-web mailing list