Skip to content

Commit

Permalink
Merge pull request cobbler#300 from jimi1283/issue_287
Browse files Browse the repository at this point in the history
BUGFIX - Issue cobbler#287 - patch to allow templar to work without a config object
  • Loading branch information
jimi-c committed Sep 11, 2012
2 parents be12910 + 3eccad6 commit 312f80d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cobbler/templar.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ def __init__(self,config,logger=None):
Constructor
"""

self.config = config
self.api = config.api
self.settings = config.settings()
self.config = None
self.settings = None
if config:
self.config = config
self.settings = config.settings()

self.last_errors = []

if logger is None:
Expand All @@ -74,7 +77,7 @@ def check_for_invalid_imports(self,data):
for line in lines:
if line.find("#import") != -1:
rest=line.replace("#import","").replace(" ","").strip()
if rest not in self.settings.cheetah_import_whitelist:
if self.settings and rest not in self.settings.cheetah_import_whitelist:
raise CX("potentially insecure import in template: %s" % rest)

def render(self, data_input, search_table, out_path, subject=None, template_type=None):
Expand All @@ -96,7 +99,7 @@ def render(self, data_input, search_table, out_path, subject=None, template_type
if not template_type:
# Assume we're using the default template type, if set in
# the settinigs file or use cheetah as the last resort
if self.settings.default_template_type:
if self.settings and self.settings.default_template_type:
template_type = self.settings.default_template_type
else:
template_type = "cheetah"
Expand Down

0 comments on commit 312f80d

Please sign in to comment.