From b580a3138d46933331cd9829c7dcb3f4135a194f Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Fri, 13 Aug 2010 12:51:07 -0400 Subject: Updated ElementBase.enable and ElementBase.initPlugin --- sleekxmpp/xmlstream/stanzabase.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'sleekxmpp') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index b11d59ee..aba63331 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -108,6 +108,29 @@ class ElementBase(object): # We did not generate XML 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 def attrib(self): #backwards compatibility return self @@ -191,14 +214,6 @@ class ElementBase(object): def findall(self, 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): if attrib == 'substanzas': return self.iterables -- cgit v1.2.3