Mercurial > genshi > genshi-test
view 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 |
line wrap: on
line source
import os from genshi.template import TemplateLoader import web loader = TemplateLoader([os.path.dirname(os.path.abspath(__file__))], auto_reload=True) urls = ('/(.*)', 'hello') class hello(object): def GET(self, name): i = web.input(times=1) if not name: name = 'world' name = name.decode('utf-8') tmpl = loader.load('hello.html') stream = tmpl.generate(name=name, times=int(i.times)) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) print stream.render('html') if __name__ == '__main__': web.webapi.internalerror = web.debugerror web.run(urls, globals())