Commit 66276798 authored by Jérome Perrin's avatar Jérome Perrin

Experiments to demonstrate that we can get a traceback when using a Loader

This is not a patch to add traceback support, just a way to proove that with a loader instead of from_string the traceback properly contain the template code and can be debugged using pdb
parent e9b7c1b2
......@@ -125,6 +125,15 @@ class FolderLoader(RecipeBaseLoader):
return path
return None
class MyLoader(BaseLoader):
def __init__(self, file_name, source):
self.file_name = file_name
self.source = source
def get_source(self, environment, template):
return self.source, self.file_name, lambda: True
LOADER_TYPE_DICT = {
'rawfile': (FileLoader, EXPRESSION_HANDLER['raw']),
'file': (FileLoader, getKey),
......@@ -140,9 +149,11 @@ class Recipe(object):
def __init__(self, buildout, name, options):
template = options['template']
if template.startswith('inline:'):
self.template_name = "inline"
template = template[7:].lstrip('\r\n')
self.get_template = lambda: template
else:
self.template_name = template
template = zc.buildout.download.Download(
buildout['buildout'],
hash_name=True,
......@@ -212,9 +223,9 @@ class Recipe(object):
Environment(
extensions=self.extension_list,
undefined=StrictUndefined,
loader=self.loader,
).from_string(
self.get_template(),
loader=MyLoader(self.template_name, self.get_template())
).get_template(
self.template_name
).render(
**self.context
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment