[Twisted-web] large file upload in web2 (was Re: http.HTTPFactory(site) equivalent in web2.0.2?)

David Reid dreid at dreid.org
Tue Jun 27 12:26:38 CDT 2006

Hash: SHA1

Lenny G Arbage wrote:
>   I just found it yesterday (in 0.1) and thought I
> should upgrade to 0.2 before bugging anyone about it. 
> I'd be happy to create a bug, but I have no idea how
> to do that ("TICKET_CREATE privileges are required to
> perform this operation", and I haven't been able to
> get myself over the wall of "where are the
> instructions on getting an account or gaining those
> privileges?")

There is a register link.

>   Here, though, is a simple example illustrating the
> problem:
>         while True:
>             buf = file.read(READSIZE)
>             tot = tot + READSIZE
>             print "reading %d..." % tot
>             if buf == '':
>                 break
>             destfile.write(buf)

Ok, while True is bad and blocking.  I think you should look at
twisted.web2.static.FileSaver, if it doesn' perform a function close
enough to what you want it is a good example of the right way to handle
uploaded files as far as reading. (Hint it's to use things in the
twisted.web2.stream library)  I expect your problems will go away but
you might still want to file a documentation enhancement bug stating
that how to do this kind of thing is completely undocumented.

- -David

- --
"Usually the protocol is this: I appoint someone for a task,
which they are not qualified to do.  Then, they have to fight
a bear if they don't want to do it." -- Glyph Lefkowitz
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Twisted-web mailing list