Skip to content
Myr

Updated examples to use Django cached.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 53cafcc · Browse files · 3 files+15 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−8 removed

  • other:+15 added−8 removed

3 files+15 added−8 removed

modified:examples/rwbench/djangoext.py+8 added-1 removed
1# -*- coding: utf-8 -*-2from rwbench import ROOT3from os.path import join4from django.conf import settings5settings.configure(TEMPLATE_DIRS=(join(ROOT, 'django'),))5settings.configure(6 TEMPLATE_DIRS=(join(ROOT, 'django'),),7 TEMPLATE_LOADERS=(8 ('django.template.loaders.cached.Loader', (9 'django.template.loaders.filesystem.Loader',10 )),11 )12)13from django.template import loader as django_loader, Context as DjangoContext, \14 Node, NodeList, Variable, TokenParser15from django import template as django_template_module16from django.template import Library
119 unmodified lines
modified:examples/bench.py+3 added-6 removed
101 unmodified lines
102 from django.template import Template as DjangoTemplate, Context as DjangoContext103except ImportError:104 test_django = None105else:106 django_template = """\106 django_template = DjangoTemplate("""\107<!doctype html>108<html>109 <head>110 <title>{{ page_title }}</title>
19 unmodified lines
130 </table>131 </div>132 </body>133</html>\134"""134""")135136 def test_django():137 c = DjangoContext(context)138 c['navigation'] = [('index.html', 'Index'), ('downloads.html', 'Downloads'),139 ('products.html', 'Products')]140 # recompile template each rendering because that's what django141 # is doing in normal situations too. Django is not thread safe142 # so we can't cache it in regular apps either.143 DjangoTemplate(django_template).render(c)140 django_template.render(c)141142try:143 from mako.template import Template as MakoTemplate144except ImportError:
214 unmodified lines
modified:examples/profile.py+4 added-1 removed
9 unmodified lines
10 'table': [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)]11}1213source = """\14% macro testmacro(x)15 <span>{{ x }}</span>16% endmacro17<!doctype html>18<html>19 <head>20 <title>${page_title|e}</title>
6 unmodified lines
27 <table>28 % for row in table29 <tr>30 % for cell in row28 <td>${cell}</td>31 <td>${testmacro(cell)}</td>32 % endfor33 </tr>34 % endfor35 </table>
17 unmodified lines