Permalink
Browse files

Stripped out explicit references to kid and cheetah.

  • Loading branch information...
ralphbean committed Apr 28, 2012
1 parent 3268c26 commit 595ba7c6c84e5f8201760dc96eb71b5fc8bb4058
@@ -28,9 +28,7 @@ def get_description(fname='README.rst'):
return ''.join(lines)
# Requirements to install buffet plugins and engines
_extra_cheetah = ["Cheetah>=1.0", "TurboCheetah>=0.9.5"]
_extra_genshi = ["Genshi >= 0.3.5"]
_extra_kid = ["kid>=0.9.5", "TurboKid>=0.9.9"]
_extra_mako = ["Mako >= 0.1.1"]
setup(
@@ -53,11 +51,9 @@ def get_description(fname='README.rst'):
'FormEncode',
'WebTest',
'strainer',
] + _extra_kid + _extra_cheetah + _extra_genshi + _extra_mako,
] + _extra_genshi + _extra_mako,
test_suite = 'nose.collector',
extras_require = {
'cheetah': _extra_cheetah,
'kid': _extra_kid,
'genshi': _extra_genshi,
'mako': _extra_mako,
},
@@ -5,11 +5,8 @@
from tw2.core.template import reset_engine_name_cache
# TBD: only test engines that are installed
engines = ['cheetah', 'kid', 'genshi', 'mako']
engines = ['genshi', 'mako']
kid_prefix = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n"""
def strip_prefix(prefix, s):
return s[len(prefix):] if isinstance(s, basestring) and s.startswith(prefix) else s
class TestWD(twc.Widget):
test = twc.Param(default='bob')
@@ -27,21 +24,7 @@ def _check_render(self, template, data, expected, engine=None):
assert out == expected, out
def test_auto_select_engine(self):
#im not sure why this test fails with kid, but this is the error:
#Traceback (most recent call last):
#File "/.../lib/python2.5/site-packages/nose-0.11.0-py2.5.egg/nose/case.py", line 183, in runTest
#self.test(*self.arg)
#File "/.../tw2core-percious/tests/test_template.py", line 22, in _check_render
#out = twc.template.EngineManager().render(template, 'string', data)
#File "/.../src/tw2core-percious/tw2/core/template.py", line 44, in render
#template = self[engine_name].load_template(template_path)
#File "/.../lib/python2.5/site-packages/TurboKid-1.0.4-py2.5.egg/turbokid/kidsupport.py", line 151, in load_template
#tclass = mod.Template
#AttributeError: 'module' object has no attribute 'Template'
engs = engines[:]
engs.remove('kid')
for engine in engs:
for engine in engines:
#set up the default renderers
yield self._check_render, 'tw2.core.test_templates.simple', {'test':engine}, '<p>TEST %s</p>'%engine, engine
@@ -71,15 +54,13 @@ def test_engines(self):
for engine in engines:
print "Testing %s..." % engine
out = twc.template.EngineManager().render('%s:tw2.core.test_templates.simple_%s' % (engine, engine), 'string', {'test':'test1'})
out = strip_prefix(kid_prefix, out)
assert(isinstance(out, unicode))
assert(out == '<p>TEST test1</p>')
def test_engines_unicode(self):
for engine in engines:
print "Testing %s..." % engine
out = twc.template.EngineManager().render('%s:tw2.core.test_templates.simple_%s' % (engine, engine), 'string', {'test':'test\u1234'})
out = strip_prefix(kid_prefix, out)
assert(out == '<p>TEST test\u1234</p>')
def test_engine_dupe(self):
@@ -100,11 +81,13 @@ def test_engine_notfound(self):
def test_extra_vars(self):
eng = twc.template.EngineManager()
for engine in engines[:3]: #mako is exempt
for engine in engines:
# mako is exempt
if engine == 'mako':
continue
print "Testing %s..." % engine
eng.load_engine(engine, extra_vars_func=lambda: {'test':'wobble'})
out = eng.render('%s:tw2.core.test_templates.simple_%s' % (engine, engine), 'string', {})
out = strip_prefix(kid_prefix, out)
assert(out == '<p>TEST wobble</p>')
def test_nesting(self):
@@ -114,19 +97,18 @@ def test_nesting(self):
for inner in engines:
print 'Testing %s on %s' % (inner, outer)
test = eng.render('%s:tw2.core.test_templates.simple_%s' % (inner, inner), outer, {'test':'test1'})
test = strip_prefix(kid_prefix, test)
out = eng.render('%s:tw2.core.test_templates.simple_%s' % (outer, outer), 'string', {'test':test})
out = strip_prefix(kid_prefix, out)
print out
assert(out == '<p>TEST <p>TEST test1</p></p>')
def test_widget_display(self):
twc.core.request_local()['middleware'] = twc.make_middleware(None)
mtest = TestWD(id='x')
for eng in engines:
print eng
test = mtest.req()
test.template = '%s:tw2.core.test_templates.inner_%s' % (eng, eng)
out = strip_prefix(kid_prefix, test.display())
out = test.display()
assert(out == '<p>TEST bob</p>')
def test_widget_nesting(self):
@@ -139,7 +121,7 @@ def test_widget_nesting(self):
TestWD(id='y', template='%s:tw2.core.test_templates.inner_%s' % (inner, inner)),
]
)
assert(test.display().replace(kid_prefix, '') == '<p>TEST <p>TEST bob</p></p>')
assert(test.display() == '<p>TEST <p>TEST bob</p></p>')
def test_genshi_abs(self):
test_dir = os.path.sep.join(__file__.split(os.path.sep)[:-1])
@@ -74,7 +74,7 @@ class Config(object):
`preferred_rendering_engines`
List of rendering engines in order of preference.
(default: ['mako','genshi','kid','cheetah'])
(default: ['mako','genshi'])
`strict_engine_selection`
If set to true, TW2 will only select rendering engines from within your
@@ -84,7 +84,7 @@ class Config(object):
`rendering_engine_lookup`
A dictionary of file extensions you expect to use for each type of
template engine.
(default: {'mako':'mak','genshi':'html','cheetah':'tmpl','kid':'kid'})
(default: {'mako':'mak','genshi':'html'})
`script_name`
A name to prepend to the url for all resource links (different from
@@ -107,13 +107,11 @@ class Config(object):
validator_msgs = {}
encoding = 'utf-8'
auto_reload_templates = None
preferred_rendering_engines = ['mako', 'genshi', 'cheetah', 'kid']
preferred_rendering_engines = ['mako', 'genshi']
strict_engine_selection = True
rendering_extension_lookup = {
'mako': 'mak',
'genshi': 'html',
'cheetah': 'tmpl',
'kid': 'kid',
}
script_name = ''
@@ -28,8 +28,6 @@ def template_available(template_name, engine_name, mw=None):
rendering_extension_lookup = {
'mako': 'mak',
'genshi': 'html',
'cheetah': 'tmpl',
'kid': 'kid',
}
ext = rendering_extension_lookup[engine_name]
@@ -69,14 +67,14 @@ def get_engine_name(template_name, mw=None):
mw = rl['middleware']
pref_rend_eng = mw.config.preferred_rendering_engines
except (KeyError, AttributeError):
pref_rend_eng = ['mako', 'genshi', 'cheetah', 'kid']
pref_rend_eng = ['mako', 'genshi']
# find the first file in the preffered engines available for templating
for engine_name in pref_rend_eng:
if template_available(template_name, engine_name, mw):
engine_name_cache[template_name] = engine_name
return engine_name
if not mw.config.strict_engine_selection:
pref_rend_eng = ['mako', 'genshi', 'cheetah', 'kid']
pref_rend_eng = ['mako', 'genshi']
for engine_name in pref_rend_eng:
if template_available(template_name, engine_name):
engine_name_cache[template_name] = engine_name
@@ -104,7 +102,7 @@ def render(self, template, displays_on, dct):
if engine_name == 'genshi' and '/' in template_path:
engine_name = 'genshi_abs'
if engine_name not in ['string', 'cheetah']:
if engine_name not in ['string']:
template = self[engine_name].load_template(template_path)
if engine_name == 'string':

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -37,8 +37,6 @@
rendering_extension_lookup = {
'mako': 'mak',
'genshi': 'html',
'cheetah': 'tmpl',
'kid': 'kid',
}
rm = pk.ResourceManager()

0 comments on commit 595ba7c

Please sign in to comment.