summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-02-26 13:27:35 -0600
committerSol Jerome <sol.jerome@gmail.com>2011-02-26 13:27:35 -0600
commit1dcb73e1a06d3a558b498ec5d5a47ff562254b7d (patch)
treef70221ed6dcb402936f1b7f5fd17d2b850f1091b /src/lib/Server
parentfec3476b511912b0a8761499449ad23858eed362 (diff)
downloadbcfg2-1dcb73e1a06d3a558b498ec5d5a47ff562254b7d.tar.gz
bcfg2-1dcb73e1a06d3a558b498ec5d5a47ff562254b7d.tar.bz2
bcfg2-1dcb73e1a06d3a558b498ec5d5a47ff562254b7d.zip
Bundler: Add support for genshi .xml bundles
This commit modifies the Bundler plugin to allow for genshi templates with .xml file extensions via the xml namespace (Resolves ticket #861). Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Plugins/Bundler.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py
index 47cd7e2c4..3f88fe26b 100644
--- a/src/lib/Server/Plugins/Bundler.py
+++ b/src/lib/Server/Plugins/Bundler.py
@@ -15,17 +15,22 @@ try:
except:
have_genshi = False
+
class BundleFile(Bcfg2.Server.Plugin.StructFile):
+
def get_xml_value(self, metadata):
bundlename = self.name.split('/')[-1][:-4]
bundle = lxml.etree.Element('Bundle', name=bundlename)
[bundle.append(copy.deepcopy(item)) for item in self.Match(metadata)]
return bundle
+
class Bundler(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Structure,
Bcfg2.Server.Plugin.XMLDirectoryBacked):
- """The bundler creates dependent clauses based on the bundle/translation scheme from Bcfg1."""
+ """The bundler creates dependent clauses based on the
+ bundle/translation scheme from Bcfg1.
+ """
name = 'Bundler'
__version__ = '$Id$'
__author__ = 'bcfg-dev@mcs.anl.gov'
@@ -37,14 +42,26 @@ class Bundler(Bcfg2.Server.Plugin.Plugin,
self.encoding = core.encoding
self.__child__ = self.template_dispatch
try:
- Bcfg2.Server.Plugin.XMLDirectoryBacked.__init__(self, self.data, self.core.fam)
+ Bcfg2.Server.Plugin.XMLDirectoryBacked.__init__(self,
+ self.data,
+ self.core.fam)
except OSError:
self.logger.error("Failed to load Bundle repository")
raise Bcfg2.Server.Plugin.PluginInitError
def template_dispatch(self, name):
+ bundle = lxml.etree.parse(name)
+ nsmap = bundle.getroot().nsmap
if name.endswith('.xml'):
- return BundleFile(name)
+ if have_genshi and \
+ (nsmap == {'py': 'http://genshi.edgewall.org/'}):
+ # allow for genshi bundles with .xml extensions
+ spec = Bcfg2.Server.Plugin.Specificity()
+ return Bcfg2.Server.Plugins.SGenshi.SGenshiTemplateFile(name,
+ spec,
+ self.encoding)
+ else:
+ return BundleFile(name)
elif name.endswith('.genshi'):
if have_genshi:
spec = Bcfg2.Server.Plugin.Specificity()