summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/TCheetah.py
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2010-08-05 21:33:52 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-08-05 16:33:58 -0500
commit0c366586f5037f2f91ac0452fc47936ddb9716e3 (patch)
treec0499e502948c162478e9c89d7cd0eaffc3133a8 /src/lib/Server/Plugins/TCheetah.py
parent5536c3d4017ccc4177821904316fe67b909efe72 (diff)
downloadbcfg2-0c366586f5037f2f91ac0452fc47936ddb9716e3.tar.gz
bcfg2-0c366586f5037f2f91ac0452fc47936ddb9716e3.tar.bz2
bcfg2-0c366586f5037f2f91ac0452fc47936ddb9716e3.zip
TGenshi/TCheetah: Add base64 encoding support for files handled by non-Cfg plugins
Reported by Chris Brinker in IRC. We should now have the ability to use encoding=base64 in info/info.xml files for paths that are handled by the TGenshi and TCheetah plugins. I think this common code for the three plugins can be merged once we implement Kisielk's idea for having a single Cfg/TGenshi/TCheetah tree. Signed-off-by: Sol Jerome <sol.jerome@gmail.com> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@6002 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/TCheetah.py')
-rw-r--r--src/lib/Server/Plugins/TCheetah.py7
1 files changed, 6 insertions, 1 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]