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