[Twisted-web] Twisted-web Digest, Vol 105, Issue 2

Levi Nie levinie001 at gmail.com
Tue Jan 15 04:58:06 EST 2013


tks


2013/1/6 <twisted-web-request at twistedmatrix.com>

> Send Twisted-web mailing list submissions to
>         twisted-web at twistedmatrix.com
>
> 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
>         twisted-web-request at twistedmatrix.com
>
> You can reach the person managing the list at
>         twisted-web-owner at twistedmatrix.com
>
> 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?
>       (exarkun at twistedmatrix.com)
>    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 <peter.westlake at pobox.com>
> Subject: Re: [Twisted-web] [Twisted-Python] Speed of rendering?
> To: Twisted Web World <twisted-web at twistedmatrix.com>
> Message-ID:
>         <
> 1357324247.31399.140661173476561.11F56E5E at 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: exarkun at twistedmatrix.com
> Subject: Re: [Twisted-web] [Twisted-Python] Speed of rendering?
> To: Twisted Web World <twisted-web at twistedmatrix.com>
> Message-ID:
>
> <20130104195813.4649.1661214274.divmod.xquotient.20 at localhost6.localdomain6
> >
>
> Content-Type: text/plain; charset="utf-8"; format="flowed"
>
> On 06:30 pm, peter.westlake at pobox.com 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
> >Twisted-web at twistedmatrix.com
> >http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sat, 5 Jan 2013 09:50:37 +0800
> From: Levi Nie <levinie001 at gmail.com>
> Subject: [Twisted-web] file upload with twisted
> To: "twisted-web at twistedmatrix.com" <twisted-web at twistedmatrix.com>
> Message-ID:
>         <CAEMsKDudEvLCeVf=
> sVPW_BE7rX2qtx9rAQERvssAMsckF9yYfA at mail.gmail.com>
> 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 <glyph at twistedmatrix.com>
> Subject: Re: [Twisted-web] file upload with twisted
> To: Twisted Web World <twisted-web at twistedmatrix.com>
> Message-ID: <DEA8BBC4-E7C6-446B-90A3-BA1037BD1267 at twistedmatrix.com>
> Content-Type: text/plain; charset=iso-8859-1
>
>
> On Jan 4, 2013, at 5:50 PM, Levi Nie <levinie001 at gmail.com> 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: ??????? ????? <poisonoff at gmail.com>
> Subject: Re: [Twisted-web] file upload with twisted
> To: Twisted Web World <twisted-web at twistedmatrix.com>
> Message-ID:
>         <CACgbmJ=
> G-FZZee62VADTV2FcLUxu0zC4PY9R3LUa2CU7tVP2Lg at mail.gmail.com>
> 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 <glyph at twistedmatrix.com> wrote:
> >
> > On Jan 4, 2013, at 5:50 PM, Levi Nie <levinie001 at gmail.com> 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
> > Twisted-web at twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
>
> ------------------------------
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
> End of Twisted-web Digest, Vol 105, Issue 2
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20130115/7bd647e4/attachment-0001.htm 


More information about the Twisted-web mailing list