[Twisted-Python] twisted.web questions

Allen Bierbaum abierbaum at gmail.com
Mon Jun 14 11:28:18 EDT 2010

On Mon, Jun 14, 2010 at 8:38 AM, Itamar Turner-Trauring <itamar at itamarst.org
> wrote:

> 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.

That is unfortunate.  Do you know of an example that shows to get access to
that file or does it just show up as a file object in the request?

> > 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.

I will have to try that.  I think it may have problems due to those systems
relying upon the WSGI interface and thus the environ dictionary.  I am
guessing I will have to hack them up a bit to make it work.

> > 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.

I mispoke.  I didn't mean the OS environment variables, I meant the
equivalent of the WSGI environ dictionary (the CGI environment).  The link
below looks like a great starting point to find them.

> 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
Is there anything that is currently holding this up?  (ie. is the design on
this branch what will end up in the system or could it change dramatically?)

Thanks for all the answers.


> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100614/938a714b/attachment.htm 

More information about the Twisted-Python mailing list