Skip to content

Commit

Permalink
MessageFormatter: store the template instead of the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît Allard committed Oct 25, 2016
1 parent 1b49923 commit 63d7463
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions master/buildbot/reporters/message.py
Expand Up @@ -23,11 +23,14 @@ def __init__(self, template_name=None, template_dir=None, template_type=None):
template_dir = os.path.join(os.path.dirname(__file__), "templates")

loader = jinja2.FileSystemLoader(template_dir)
self.env = jinja2.Environment(
env = jinja2.Environment(
loader=loader, undefined=jinja2.StrictUndefined)

if template_name is not None:
self.template_name = template_name

self.template = env.get_template(self.template_name)

if template_type is not None:
self.template_type = template_type

Expand Down Expand Up @@ -114,7 +117,6 @@ def __call__(self, mode, buildername, buildset, build, master, previous_results,
ss_list = buildset['sourcestamps']
results = build['results']

tpl = self.env.get_template(self.template_name)
cxt = dict(results=build['results'],
mode=mode,
buildername=buildername,
Expand All @@ -133,5 +135,5 @@ def __call__(self, mode, buildername, buildset, build, master, previous_results,
summary=self.messageSummary(build, results),
sourcestamps=self.messageSourceStamps(ss_list)
)
contents = tpl.render(cxt)
contents = self.template.render(cxt)
return {'body': contents, 'type': self.template_type}

0 comments on commit 63d7463

Please sign in to comment.