<div dir="ltr">tks</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/6 <span dir="ltr"><<a href="mailto:twisted-web-request@twistedmatrix.com" target="_blank">twisted-web-request@twistedmatrix.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Twisted-web mailing list submissions to<br>
<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:twisted-web-request@twistedmatrix.com">twisted-web-request@twistedmatrix.com</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:twisted-web-owner@twistedmatrix.com">twisted-web-owner@twistedmatrix.com</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Twisted-web digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: [Twisted-Python] Speed of rendering? (Peter Westlake)<br>
2. Re: [Twisted-Python] Speed of rendering?<br>
(<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>)<br>
3. file upload with twisted (Levi Nie)<br>
4. Re: file upload with twisted (Glyph)<br>
5. Re: file upload with twisted (??????? ?????)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 04 Jan 2013 18:30:47 +0000<br>
From: Peter Westlake <<a href="mailto:peter.westlake@pobox.com">peter.westlake@pobox.com</a>><br>
Subject: Re: [Twisted-web] [Twisted-Python] Speed of rendering?<br>
To: Twisted Web World <<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>><br>
Message-ID:<br>
<<a href="mailto:1357324247.31399.140661173476561.11F56E5E@webmail.messagingengine.com">1357324247.31399.140661173476561.11F56E5E@webmail.messagingengine.com</a>><br>
<br>
Content-Type: text/plain<br>
<br>
A while back I promised to write some benchmarks for<br>
twisted.web.template's flattening functions. Is something like this<br>
suitable? If so, I'll add lots more test cases. The output format could<br>
be improved, too - any preferences?<br>
<br>
Peter.<br>
<br>
from twisted.web.template import flatten<br>
from twisted.web.server import Request<br>
import twisted.web.http<br>
<br>
channel = twisted.web.http.HTTPChannel()<br>
request = Request(channel, False)<br>
<br>
<br>
def make(content):<br>
def f():<br>
d = flatten(request, content, lambda _: None)<br>
assert d.called<br>
return f<br>
<br>
<br>
def test(content):<br>
return timeit.timeit(stmt=make(content), number=repeats)<br>
<br>
repeats = 1000<br>
<br>
deeplist = ['centre']<br>
for n in range(100):<br>
deeplist = [deeplist]<br>
<br>
tests = {<br>
'empty': '',<br>
'string': 'hello',<br>
'shortlist': ['hello'],<br>
'longlist': [str(n) for n in range(100)],<br>
'deeplist': deeplist,<br>
}<br>
<br>
<br>
if __name__ == '__main__':<br>
import timeit<br>
from sys import argv<br>
for name in argv[1:] or tests:<br>
print name, test(tests[name])<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 04 Jan 2013 19:58:13 -0000<br>
From: <a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a><br>
Subject: Re: [Twisted-web] [Twisted-Python] Speed of rendering?<br>
To: Twisted Web World <<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>><br>
Message-ID:<br>
<20130104195813.4649.1661214274.divmod.xquotient.20@localhost6.localdomain6><br>
<br>
Content-Type: text/plain; charset="utf-8"; format="flowed"<br>
<br>
On 06:30 pm, <a href="mailto:peter.westlake@pobox.com">peter.westlake@pobox.com</a> wrote:<br>
>A while back I promised to write some benchmarks for<br>
>twisted.web.template's flattening functions. Is something like this<br>
>suitable? If so, I'll add lots more test cases. The output format could<br>
>be improved, too - any preferences?<br>
<br>
The output should be something that we can load into our codespeed<br>
instance. The output of any of the existing benchmarks in lp:twisted-<br>
benchmarks should be a good example of that format (I don't even recall<br>
what it is right now - it may not even be a "format" so much as a shape<br>
of data to submit to an HTTP API).<br>
<br>
The `timeit` module is probably not suitable to use to collect the data,<br>
as it makes some questionable choices with respect to measurement<br>
technique, and at the very least it's inconsistent with the rest of the<br>
benchmarks we have.<br>
<br>
Selecting data to operate on is probably an important part of this<br>
benchmark (or collection of benchmarks). It may not be possible to<br>
capture all of the interesting performance characteristics in a single<br>
dataset. However, at least something that includes HTML tags is<br>
probably desirable, since that is the primary use-case.<br>
<br>
There are some other Python templating systems with benchmarks. One<br>
approach that might make sense is to try to build analogous benchmarks<br>
for twisted.web.template. (Or perhaps a little thought will reveal that<br>
it's not possible to make comparisons between twisted.web.template and<br>
those systems, so there's no reason to follow their benchmarking lead.)<br>
<br>
Jean-Paul<br>
>Peter.<br>
><br>
>from twisted.web.template import flatten<br>
>from twisted.web.server import Request<br>
>import twisted.web.http<br>
><br>
>channel = twisted.web.http.HTTPChannel()<br>
>request = Request(channel, False)<br>
><br>
><br>
>def make(content):<br>
> def f():<br>
> d = flatten(request, content, lambda _: None)<br>
> assert d.called<br>
> return f<br>
><br>
><br>
>def test(content):<br>
> return timeit.timeit(stmt=make(content), number=repeats)<br>
><br>
>repeats = 1000<br>
><br>
>deeplist = ['centre']<br>
>for n in range(100):<br>
> deeplist = [deeplist]<br>
><br>
>tests = {<br>
> 'empty': '',<br>
> 'string': 'hello',<br>
> 'shortlist': ['hello'],<br>
> 'longlist': [str(n) for n in range(100)],<br>
> 'deeplist': deeplist,<br>
>}<br>
><br>
><br>
>if __name__ == '__main__':<br>
> import timeit<br>
> from sys import argv<br>
> for name in argv[1:] or tests:<br>
> print name, test(tests[name])<br>
><br>
>_______________________________________________<br>
>Twisted-web mailing list<br>
><a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Sat, 5 Jan 2013 09:50:37 +0800<br>
From: Levi Nie <<a href="mailto:levinie001@gmail.com">levinie001@gmail.com</a>><br>
Subject: [Twisted-web] file upload with twisted<br>
To: "<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>" <<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>><br>
Message-ID:<br>
<CAEMsKDudEvLCeVf=<a href="mailto:sVPW_BE7rX2qtx9rAQERvssAMsckF9yYfA@mail.gmail.com">sVPW_BE7rX2qtx9rAQERvssAMsckF9yYfA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
When i send a http request with a big file, can i check the content-length<br>
then enable or disable the<br>
file upload?<br>
<br>
I use the s3cmd client sent the request. And i need disable the file upload<br>
if the file size is over the quota.<br>
<br>
how can i do this?<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://twistedmatrix.com/pipermail/twisted-web/attachments/20130105/43bc7e14/attachment.html" target="_blank">http://twistedmatrix.com/pipermail/twisted-web/attachments/20130105/43bc7e14/attachment.html</a><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Fri, 4 Jan 2013 20:14:51 -0800<br>
From: Glyph <<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>><br>
Subject: Re: [Twisted-web] file upload with twisted<br>
To: Twisted Web World <<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>><br>
Message-ID: <<a href="mailto:DEA8BBC4-E7C6-446B-90A3-BA1037BD1267@twistedmatrix.com">DEA8BBC4-E7C6-446B-90A3-BA1037BD1267@twistedmatrix.com</a>><br>
Content-Type: text/plain; charset=iso-8859-1<br>
<br>
<br>
On Jan 4, 2013, at 5:50 PM, Levi Nie <<a href="mailto:levinie001@gmail.com">levinie001@gmail.com</a>> wrote:<br>
<br>
> When i send a http request with a big file, can i check the content-length then enable or disable the<br>
> file upload?<br>
><br>
> I use the s3cmd client sent the request. And i need disable the file upload if the file size is over the quota.<br>
><br>
> how can i do this?<br>
<br>
This s3cmd? <a href="https://github.com/s3tools/s3cmd/blob/master/s3cmd" target="_blank">https://github.com/s3tools/s3cmd/blob/master/s3cmd</a><br>
<br>
It doesn't look like it uses Twisted, so I don't think this is a question for this list.<br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Sat, 5 Jan 2013 15:25:21 +0600<br>
From: ??????? ????? <<a href="mailto:poisonoff@gmail.com">poisonoff@gmail.com</a>><br>
Subject: Re: [Twisted-web] file upload with twisted<br>
To: Twisted Web World <<a href="mailto:twisted-web@twistedmatrix.com">twisted-web@twistedmatrix.com</a>><br>
Message-ID:<br>
<CACgbmJ=<a href="mailto:G-FZZee62VADTV2FcLUxu0zC4PY9R3LUa2CU7tVP2Lg@mail.gmail.com">G-FZZee62VADTV2FcLUxu0zC4PY9R3LUa2CU7tVP2Lg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
I resolve same problem in self project, reimplement method<br>
handleContentChunk in server.Request<br>
<br>
My code:<br>
<br>
<code># For maximum<br>
handleContentChunkLength = 0<br>
<br>
def handleContentChunk(self, data):<br>
"""<br>
Write a chunk of data.<br>
"""<br>
self.handleContentChunkLength += len(data)<br>
<br>
if self.handleContentChunkLength >= WEB_LIMIT_REQUEST_SIZE:<br>
self.transport.write(b"HTTP/1.1 413 Request Entity Too Large\r\n\r\n")<br>
self.transport.loseConnection()<br>
<br>
# Raise to log error<br>
raise ValueError('Maximum length equal')<br>
<br>
self.content.write(data)</code><br>
<br>
On Sat, Jan 5, 2013 at 10:14 AM, Glyph <<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>> wrote:<br>
><br>
> On Jan 4, 2013, at 5:50 PM, Levi Nie <<a href="mailto:levinie001@gmail.com">levinie001@gmail.com</a>> wrote:<br>
><br>
>> When i send a http request with a big file, can i check the content-length then enable or disable the<br>
>> file upload?<br>
>><br>
>> I use the s3cmd client sent the request. And i need disable the file upload if the file size is over the quota.<br>
>><br>
>> how can i do this?<br>
><br>
> This s3cmd? <a href="https://github.com/s3tools/s3cmd/blob/master/s3cmd" target="_blank">https://github.com/s3tools/s3cmd/blob/master/s3cmd</a><br>
><br>
> It doesn't look like it uses Twisted, so I don't think this is a question for this list.<br>
><br>
><br>
> _______________________________________________<br>
> Twisted-web mailing list<br>
> <a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
> <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br>
<br>
End of Twisted-web Digest, Vol 105, Issue 2<br>
*******************************************<br>
</blockquote></div><br></div>