Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated examples to use Django cached.

--HG--
branch : trunk
  • Loading branch information...
commit f60232d52b71555e48b6c799f01e512cffa7429c 1 parent 53cafcc
@mitsuhiko authored
View
9 examples/bench.py
@@ -103,7 +103,7 @@ def test_tornado():
except ImportError:
test_django = None
else:
- django_template = """\
+ django_template = DjangoTemplate("""\
<!doctype html>
<html>
<head>
@@ -131,16 +131,13 @@ def test_tornado():
</div>
</body>
</html>\
-"""
+""")
def test_django():
c = DjangoContext(context)
c['navigation'] = [('index.html', 'Index'), ('downloads.html', 'Downloads'),
('products.html', 'Products')]
- # recompile template each rendering because that's what django
- # is doing in normal situations too. Django is not thread safe
- # so we can't cache it in regular apps either.
- DjangoTemplate(django_template).render(c)
+ django_template.render(c)
try:
from mako.template import Template as MakoTemplate
View
5 examples/profile.py
@@ -11,6 +11,9 @@
}
source = """\
+% macro testmacro(x)
+ <span>{{ x }}</span>
+% endmacro
<!doctype html>
<html>
<head>
@@ -25,7 +28,7 @@
% for row in table
<tr>
% for cell in row
- <td>${cell}</td>
+ <td>${testmacro(cell)}</td>
% endfor
</tr>
% endfor
View
9 examples/rwbench/djangoext.py
@@ -2,7 +2,14 @@
from rwbench import ROOT
from os.path import join
from django.conf import settings
-settings.configure(TEMPLATE_DIRS=(join(ROOT, 'django'),))
+settings.configure(
+ TEMPLATE_DIRS=(join(ROOT, 'django'),),
+ TEMPLATE_LOADERS=(
+ ('django.template.loaders.cached.Loader', (
+ 'django.template.loaders.filesystem.Loader',
+ )),
+ )
+)
from django.template import loader as django_loader, Context as DjangoContext, \
Node, NodeList, Variable, TokenParser
from django import template as django_template_module
Please sign in to comment.
Something went wrong with that request. Please try again.