comparison examples/basic/run.py @ 17:74cc70129d04 trunk

Refactoring to address #6: all match templates are now processed by a single filter, which means that match templates added by included templates are properly applied. A side effect of this refactoring is that `Context` objects may not be reused across multiple template processing runs. Also, output filters are now applied in the `Stream.serialize()` method instead of by the `Template.generate()` method, which just makes more sense.
author cmlenz
date Sun, 18 Jun 2006 22:33:33 +0000
parents 518a8520a6e1
children b4d17897d053
comparison
equal deleted inserted replaced
16:bcba0181049c 17:74cc70129d04
15 15
16 start = datetime.now() 16 start = datetime.now()
17 tmpl = loader.load('test.html') 17 tmpl = loader.load('test.html')
18 print ' --> parse stage: ', datetime.now() - start 18 print ' --> parse stage: ', datetime.now() - start
19 19
20 ctxt = Context(hello='<world>', skin='default', hey='ZYX', bozz=None, 20 data = dict(hello='<world>', skin='default', hey='ZYX', bozz=None,
21 items=['Number %d' % num for num in range(1, 15)], 21 items=['Number %d' % num for num in range(1, 15)],
22 prefix='#') 22 prefix='#')
23 23
24 print tmpl.generate(ctxt).render(method='html') 24 print tmpl.generate(Context(**data)).render(method='html')
25 25
26 times = [] 26 times = []
27 for i in range(100): 27 for i in range(100):
28 start = datetime.now() 28 start = datetime.now()
29 list(tmpl.generate(ctxt)) 29 list(tmpl.generate(Context(**data)))
30 sys.stdout.write('.') 30 sys.stdout.write('.')
31 sys.stdout.flush() 31 sys.stdout.flush()
32 times.append(datetime.now() - start) 32 times.append(datetime.now() - start)
33 print 33 print
34 34
Copyright (C) 2012-2017 Edgewall Software