From d3548bd56110052f2d46ad664190a05391b5062b Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 24 Aug 2012 11:13:05 -0400 Subject: TemplateHelper: removed support for host- and group-specific helpers Supporting these was basically impossible due to the way Python handles bytecode compilation. For instance, 'foo.py.G10_bar' would be compiled to foo.py.G10_barc, which is then indistinguishable from a helper for the group "barc" (or, rather, a _broken_ helper for that group, since a bytecode-compiled module cannot be imported successfully). There's no performance gain from specific helpers anyway -- they all get imported -- so I removed this functionality. --- doc/server/plugins/connectors/templatehelper.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/server/plugins/connectors/templatehelper.txt b/doc/server/plugins/connectors/templatehelper.txt index 24d7f18b5..374aeb171 100644 --- a/doc/server/plugins/connectors/templatehelper.txt +++ b/doc/server/plugins/connectors/templatehelper.txt @@ -23,9 +23,8 @@ will be read and added to matching client metadata objects. See :ref:`writing-templatehelpers` below for more information on how to write TemplateHelper scripts. -TemplateHelper supports group- and host-specific helpers, so you could -create, e.g., ``foo.py.G80_test`` to create a helper that only applied -to machines in the group ``test``. +TemplateHelper does not support group- or host-specific helpers. All +helpers will be available to all clients. .. _writing-templatehelpers: @@ -34,15 +33,14 @@ Writing Helpers A helper module is just a Python module with three special conditions: -* The filename must end with ``.py`` (before any specificity - strings, e.g., ``.G80_foo`` or ``.H_blah.example.com`` +* The filename must end with ``.py`` * The module must have an attribute, ``__export__``, that lists all of the classes, functions, variables, or other symbols you wish to export from the module. -* ``data``, ``handle_event``, ``name``, and ``specific`` are reserved - names. You should not include symbols with a reserved name in - ``__export__``. Additionally, including symbols that start with an - underscore or double underscore is bad form, and may also produce +* ``data``, ``name``, ``fam``, ``Index``, and ``HandleEvent`` are + reserved names. You should not include symbols with a reserved name + in ``__export__``. Additionally, including symbols that start with + an underscore or double underscore is bad form, and may also produce errors. See ``examples/TemplateHelper`` for examples of helper modules. @@ -60,7 +58,7 @@ a HelperModule object will has, as attributes, all symbols listed in def hello(metadata): return "Hello, %s!" % metadata.hostname -To use this in a TGenshi template, we could do:: +To use this in a Genshi template, we could do:: ${metadata.TemplateHelper['hello'].hello(metadata)} -- cgit v1.2.3-1-g7c22