On Jan 25, 2012, at 5:28 AM, Gerrat wrote:

> Tristan Seligmann <mithrandi <at> mithrandi.net> writes:
> 
>> 
>> On Tue, Jun 30, 2009 at 10:44 AM, Reza Lotun<rlotun <at> gmail.com> wrote:
>>> To be safer, I do a request.content.getvalue() since content is a
>>> cStringIO object and you can never be sure if somewhere along the
>>> chain of processing someone hasn't done a .read and forgot to do a
>>> .seek(0,0).
>> 
>> You should probably do the seek/read instead, since I don't believe
>> this is guaranteed to be a cStringIO; it might be an actual file on
>> disk, or something else.
> 
> Thank You!!!
> 
> Every <stupid> example I've seen used "request.content.getvalue()" ...which
> fails miserably for me (possibly because I'm on 64bit windows - but cStringIO 
> is
> available, so I'm not sure why it's not used).  request.content.read() works
> wonderfully.  The "getvalue" method looked familiar, but I couldn't recall 
> where
> I'd seen it - only that *my* request.content doesn't have a getvalue method.  
> It
> took quite a few searches before I stumbled on your comment here which gave me
> the correct solution.

Nothing to do with 64bit windows.  twisted.web will switch to a file when the 
threshold of the upload goes above a certain size.  request.content is a 
file-like object, not any particular implementation of that protocol.

This really should be documented in 
http://twistedmatrix.com/documents/current/api/twisted.web.iweb.IRequest.html - 
it's a bug that it isn't.

-glyph
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to