diff options
author | Lance Stout <lancestout@gmail.com> | 2010-08-13 12:51:07 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-08-13 12:51:07 -0400 |
commit | b580a3138d46933331cd9829c7dcb3f4135a194f (patch) | |
tree | 77fc594ccd4de707ecdccee7cc2fa98dbdbe9c3a /sleekxmpp/xmlstream | |
parent | c20fab0f6c28bcbfbe54db687be056a9b5088ad4 (diff) | |
download | slixmpp-b580a3138d46933331cd9829c7dcb3f4135a194f.tar.gz slixmpp-b580a3138d46933331cd9829c7dcb3f4135a194f.tar.bz2 slixmpp-b580a3138d46933331cd9829c7dcb3f4135a194f.tar.xz slixmpp-b580a3138d46933331cd9829c7dcb3f4135a194f.zip |
Updated ElementBase.enable and ElementBase.initPlugin
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 31 |
1 files changed, 23 insertions, 8 deletions
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 |