[Twisted-Python] twisted.web questions

Itamar Turner-Trauring itamar at itamarst.org
Mon Jun 14 09:38:27 EDT 2010


On Mon, 2010-06-14 at 08:22 -0500, Allen Bierbaum wrote:

> 1) Is there any method to stream a large request (ex: PUT or POST with
> file upload) into the system or does the entire body have to be loaded
> into memory as part of the request?

Very large requests get written to disk, rather than memory. This is
still not ideal, streaming is obviously better - someone may be able to
suggest how to do it until Twisted gets fixed.

> 2) Has anyone used an existing URL Routing system (ex: Routes [1],
> Selector [2]) and adapted it for use with Twisted?  (I know I could
> use the twisted preferred method of parent child hierarchies, but our
> application has a better fit with the route-based method used by
> Pylons, Django, Rails, etc)

Set isLeaf=True on the Resource, and then render() will get called for
all sub-paths, and at that point you can dispatch using one of those
libraries.

> 3) Is there a document anywhere that describes all the environment
> variables the user can get from the request and how to get to them?
>  (something like the environ section of the WSGI PEP [3])

Request objects do not provide any environment variables (that's an
operating system concept). They provide information about the HTTP
request. This includes the method, path, and HTTP headers sent by the
client. The list of instance variable on Request objects may be what you
want:

http://twistedmatrix.com/documents/current/api/twisted.web.http.Request.html

> 4) Are their any wrappers people have developed to make it a bit
> easier to use deferreds (in particular inlinecallbacks) in the
> handlers for twisted.web?  (I am considering just writing a wrapper
> myself that provides an interface similar to google app engine webapp
> [4] but wanted to check first so I don't reinvent something)

There's a branch of Twisted that implements this, hopefully it will
eventually be merged:
http://twistedmatrix.com/trac/ticket/3711





More information about the Twisted-Python mailing list