diff options
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/TCheetah.py | 7 | ||||
-rw-r--r-- | src/lib/Server/Plugins/TGenshi.py | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index 91c830620..d40f4baf3 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -1,6 +1,7 @@ '''This module implements a templating generator based on Cheetah''' __revision__ = '$Revision$' +import binascii import logging import sys import traceback @@ -54,7 +55,11 @@ class TemplateFile: if type(self.template) == unicode: entry.text = self.template else: - entry.text = unicode(str(self.template), self.encoding) + if entry.get('encoding') == 'base64': + # take care of case where file needs base64 encoding + entry.text = binascii.b2a_base64(self.template) + else: + entry.text = unicode(str(self.template), self.encoding) except: (a, b, c) = sys.exc_info() msg = traceback.format_exception(a, b, c, limit=2)[-1][:-1] diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py index 4bc8338c9..29e6d7307 100644 --- a/src/lib/Server/Plugins/TGenshi.py +++ b/src/lib/Server/Plugins/TGenshi.py @@ -1,6 +1,7 @@ """This module implements a templating generator based on Genshi.""" __revision__ = '$Revision$' +import binascii import logging import Bcfg2.Server.Plugin @@ -90,7 +91,11 @@ class TemplateFile: if type(textdata) == unicode: entry.text = textdata else: - entry.text = unicode(textdata, self.encoding) + if entry.get('encoding') == 'base64': + # take care of case where file needs base64 encoding + entry.text = binascii.b2a_base64(textdata) + else: + entry.text = unicode(textdata, self.encoding) else: try: xmldata = stream.render('xml', strip_whitespace=False) |