diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-17 15:17:03 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-17 15:17:08 -0400 |
commit | 3cf1f738c0a474e21ce56604ad874241584d59e9 (patch) | |
tree | 50aafe6501d1c48ef8bf91140808adef8b912da0 /src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | |
parent | 63ca36cc3569bc5b31ffd9203d8f9d591eb9c21c (diff) | |
download | bcfg2-3cf1f738c0a474e21ce56604ad874241584d59e9.tar.gz bcfg2-3cf1f738c0a474e21ce56604ad874241584d59e9.tar.bz2 bcfg2-3cf1f738c0a474e21ce56604ad874241584d59e9.zip |
assigned Cfg handlers explicit priorities to avoid over-zealous regex matches
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py index 114cdab70..fe53ea809 100644 --- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py @@ -5,6 +5,7 @@ import os import sys import stat import logging +import operator import lxml.etree import Bcfg2.Options import Bcfg2.Server.Plugin @@ -56,6 +57,16 @@ class CfgBaseFileMatcher(Bcfg2.Server.Plugin.SpecificData): #: ``.H_client.example.com`` or ``.G10_foogroup``. __specific__ = True + #: Cfg handlers are checked in ascending order of priority to see + #: if they handle a given event. If this explicit priority is not + #: set, then + #: :class:`Bcfg2.Server.Plugins.Cfg.CfgPlaintextGenerator` would + #: match against nearly every other sort of generator file if it + #: comes first. It's not necessary to set ``__priority`` on + #: handlers where :attr:`__specific__` is False, since they don't + #: have a potentially open-ended regex + __priority__ = 0 + #: Flag to indicate a deprecated handler. deprecated = False @@ -63,14 +74,14 @@ class CfgBaseFileMatcher(Bcfg2.Server.Plugin.SpecificData): Bcfg2.Server.Plugin.SpecificData.__init__(self, name, specific, encoding) self.encoding = encoding - self.regex = self.__class__.get_regex([name]) __init__.__doc__ = Bcfg2.Server.Plugin.SpecificData.__init__.__doc__ + \ """ .. ----- .. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__basenames__ .. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__extensions__ .. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__ignore__ -.. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__specific__""" +.. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__specific__ +.. autoattribute:: Bcfg2.Server.Plugins.Cfg.CfgBaseFileMatcher.__priority__ """ @classmethod def get_regex(cls, basenames): @@ -339,6 +350,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet): if set(hdlr.__mro__).intersection([CfgInfo, CfgFilter, CfgGenerator, CfgVerifier]): self._handlers.append(hdlr) + self._handlers.sort(key=operator.attrgetter("__priority__")) return self._handlers def handle_event(self, event): |