Updated ElementBase.enable and ElementBase.initPlugin

This commit is contained in:
Lance Stout 2010-08-13 12:51:07 -04:00
parent c20fab0f6c
commit b580a3138d

View file

@ -108,6 +108,29 @@ class ElementBase(object):
# We did not generate XML # We did not generate XML
return False return False
def enable(self, attrib):
"""
Enable and initialize a stanza plugin.
Alias for initPlugin.
Arguments:
attrib -- The stanza interface for the plugin.
"""
return self.initPlugin(attrib)
def initPlugin(self, attrib):
"""
Enable and initialize a stanza plugin.
Arguments:
attrib -- The stanza interface for the plugin.
"""
if attrib not in self.plugins:
plugin_class = self.plugin_attrib_map[attrib]
self.plugins[attrib] = plugin_class(parent=self)
return self
@property @property
def attrib(self): #backwards compatibility def attrib(self): #backwards compatibility
return self return self
@ -191,14 +214,6 @@ class ElementBase(object):
def findall(self, xpath): def findall(self, xpath):
return self.xml.findall(xpath) return self.xml.findall(xpath)
def enable(self, attrib):
self.initPlugin(attrib)
return self
def initPlugin(self, attrib):
if attrib not in self.plugins:
self.plugins[attrib] = self.plugin_attrib_map[attrib](parent=self)
def __getitem__(self, attrib): def __getitem__(self, attrib):
if attrib == 'substanzas': if attrib == 'substanzas':
return self.iterables return self.iterables