summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/server/plugins/structures/bundler/index.txt15
-rw-r--r--src/lib/Server/Plugins/Bundler.py23
2 files changed, 29 insertions, 9 deletions
diff --git a/doc/server/plugins/structures/bundler/index.txt b/doc/server/plugins/structures/bundler/index.txt
index e5682ac00..0d0054a2c 100644
--- a/doc/server/plugins/structures/bundler/index.txt
+++ b/doc/server/plugins/structures/bundler/index.txt
@@ -105,13 +105,16 @@ how group entries can be used in bundles)
Genshi templates
================
-Genshi templates are used by adding a Genshi xml-style template to the
-Bundler directory with a ``.genshi`` file extension. Version 0.4 or newer
-of genshi is required.
+Genshi xml templates can be specified one of two ways:
-.. important:: The ``.genshi`` file extension is required in order for the
- server to know that the Bundle should be rendered using
- Genshi.
+1. Add an xml-style genshi template to the Bundler directory with a
+ ``.genshi`` and the associated namespace attribute.
+2. Simply add the appropriate namespace attribute to your existing xml
+ bundle.
+
+The namespace attribute in this case should look like the following::
+
+ xmlns:py="http://genshi.edgewall.org/"
Motivation
----------
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()