From c6739488e46214c3785503d220a0b3b7397a821f Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 4 Nov 2008 16:25:47 +0000 Subject: TCheetah: Use an explicit searchlist for variable resolution, which gets propagated to #included templates git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4960 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/TCheetah.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index b36e05f89..1277ce390 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -15,6 +15,7 @@ class TemplateFile: self.specific = specific self.encoding = encoding self.template = None + self.searchlist = {'properties': properties} def handle_event(self, event): '''Handle all fs events for this template''' @@ -23,8 +24,9 @@ class TemplateFile: try: s = {'useStackFrames': False} self.template = Cheetah.Template.Template(open(self.name).read(), - compilerSettings=s) - self.template.properties = self.properties.properties + compilerSettings=s, + searchList = [self.searchlist]) + except Cheetah.Parser.ParseError, perror: logger.error("Cheetah parse error for file %s" % (self.name)) logger.error(perror.report()) @@ -32,8 +34,11 @@ class TemplateFile: def bind_entry(self, entry, metadata): '''Build literal file information''' self.template.metadata = metadata + self.searchlist['metadata'] = metadata self.template.path = entry.get('realname', entry.get('name')) + self.searchlist['path'] = entry.get('realname', entry.get('name')) self.template.source_path = self.name + self.searchlist['source_path'] = self.name try: if type(self.template) == unicode: @@ -45,7 +50,7 @@ class TemplateFile: (a, b, c) = sys.exc_info() msg = traceback.format_exception(a, b, c, limit=2)[-1][:-1] logger.error(msg) - logger.error("TCheetah template error for %s" % self.template.path) + logger.error("TCheetah template error for %s" % self.searchlist['path']) del a, b, c raise Bcfg2.Server.Plugin.PluginExecutionError -- cgit v1.2.3-1-g7c22