Mercurial > genshi > genshi-test
annotate examples/webpy/hello.py @ 734:a61ab7bbe12d
Fixed some unintuitive behaviour in `Transformer.{cut,copy}`.
The old behaviour was to copy all selected events in the stream before passing
to the next transform. The new behaviour is to copy only a single contiguous
block before yielding to the next trasnform.
The previous behaviour can be preserved with the following construct:
`...copy(buffer, accumulate=True).buffer()...`
author | athomas |
---|---|
date | Wed, 04 Jun 2008 13:02:00 +0000 |
parents | 42c6cfdd5582 |
children |
rev | line source |
---|---|
267 | 1 import os |
2 from genshi.template import TemplateLoader | |
3 import web | |
4 | |
5 loader = TemplateLoader([os.path.dirname(os.path.abspath(__file__))], | |
6 auto_reload=True) | |
7 urls = ('/(.*)', 'hello') | |
8 | |
9 | |
10 class hello(object): | |
11 | |
12 def GET(self, name): | |
13 i = web.input(times=1) | |
14 if not name: | |
15 name = 'world' | |
16 name = name.decode('utf-8') | |
17 | |
18 tmpl = loader.load('hello.html') | |
19 stream = tmpl.generate(name=name, times=int(i.times)) | |
20 | |
21 web.header('Content-Type', 'text/html; charset=utf-8', unique=True) | |
271
b5b2a84e4b71
Still too much whitespace in the [WebPy web.py] example. Switch to printing the whole output at once.
cmlenz
parents:
270
diff
changeset
|
22 print stream.render('html') |
267 | 23 |
24 | |
25 if __name__ == '__main__': | |
385 | 26 web.webapi.internalerror = web.debugerror |
27 web.run(urls, globals()) |