Skip to content
Myr

[svn] Make Django and Mako optional.

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

--HG-- branch : trunk

authored by Alexander Schremmer · committed by Alexander Schremmer · parent ed03db5 · Browse files · 1 file+21 added−7 removed
This commit

State

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

Diff stats

1 file+21 added−7 removed

  • tests:+21 added−7 removed

1 file+21 added−7 removed

modified:tests/bigtable.py+21 added-7 removed
15 unmodified lines
16from genshi.template import MarkupTemplate1718from jinja import Environment1920try:20from django.conf import settings21settings.configure()22from django.template import Context as DjangoContext23from django.template import Template as DjangoTemplate21 from django.conf import settings22 settings.configure()23 from django.template import Context as DjangoContext24 from django.template import Template as DjangoTemplate25 have_django = True26except ImportError:27 have_django = False2829from Cheetah.Template import Template as CheetahTemplate3031try:27from mako.template import Template as MakoTemplate32 from mako.template import Template as MakoTemplate33 have_mako = True34except ImportError:35 have_mako = False3637table = [dict(a='1',b='2',c='3',d='4',e='5',f='6',g='7',h='8',i='9',j='10')38 for x in range(1000)]39
4 unmodified lines
44</tr>45</table>46""")4748if have_django:40django_tmpl = DjangoTemplate("""49 django_tmpl = DjangoTemplate("""50<table>51{% for row in table %}52<tr>{% for col in row.values %}{{ col|escape }}{% endfor %}</tr>53{% endfor %}
20 unmodified lines
74#end for75</table>76''', searchList=[{'table': table, 'escape': cgi.escape}])7778if have_mako:69mako_tmpl = MakoTemplate('''79 mako_tmpl = MakoTemplate('''80<table>81% for row in table:82<tr>83% for col in row.values():
5 unmodified lines
89''')9091def test_django():92 """Django Templates"""93 if not have_django:94 return95 context = DjangoContext({'table': table})96 django_tmpl.render(context)9798def test_jinja():
10 unmodified lines
109 cheetah_tmpl.respond()110111def test_mako():112 """Mako Templates"""113 if not have_mako:114 return115 mako_tmpl.render(table=table)116117118def run(which=None, number=10):
30 unmodified lines