From 285b1df3a54f4b67eadd11471f1b964142349e11 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 29 Jan 2014 17:44:41 -0500 Subject: [PATCH] Fix problem where plugins could be called twice for same data If a plugin has a default and is also explicitly defined, the pluginapi would call the code twice. Correct this by avoiding calling the default if specific info not specified already --- confluent/pluginapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/confluent/pluginapi.py b/confluent/pluginapi.py index 5d8331e1..9836392c 100644 --- a/confluent/pluginapi.py +++ b/confluent/pluginapi.py @@ -190,13 +190,15 @@ def handle_path(path, operation, configmanager, inputdata=None): elif 'pluginattrs' in plugroute: nodeattr = configmanager.get_node_attributes( [node], plugroute['pluginattrs']) + foundplug = False for attrname in plugroute['pluginattrs']: if attrname in nodeattr[node]: + foundplug = True passvalue = pluginmap[nodeattr[node][attrname]['value']].__dict__[operation]( nodes=(node,), element=pathcomponents, configmanager=configmanager, inputdata=inputdata) - if 'default' in plugroute: + if (not foundplug) and 'default' in plugroute: passvalue = pluginmap[plugroute['default']].__dict__[operation]( nodes=(node,), element=pathcomponents, configmanager=configmanager, inputdata=inputdata)