mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Updated registerStanzaPlugin and the XML test type.
This commit is contained in:
parent
4b52007e8c
commit
b0fb205c16
1 changed files with 14 additions and 8 deletions
|
@ -15,16 +15,22 @@ from xml.etree import cElementTree as ET
|
||||||
from sleekxmpp.xmlstream import JID
|
from sleekxmpp.xmlstream import JID
|
||||||
from sleekxmpp.xmlstream.tostring import tostring
|
from sleekxmpp.xmlstream.tostring import tostring
|
||||||
|
|
||||||
xmltester = type(ET.Element('xml'))
|
|
||||||
|
# Used to check if an argument is an XML object.
|
||||||
|
XML_TYPE = type(ET.Element('xml'))
|
||||||
|
|
||||||
|
|
||||||
def registerStanzaPlugin(stanza, plugin):
|
def registerStanzaPlugin(stanza, plugin):
|
||||||
"""
|
"""
|
||||||
Associate a stanza object as a plugin for another stanza.
|
Associate a stanza object as a plugin for another stanza.
|
||||||
"""
|
|
||||||
tag = "{%s}%s" % (plugin.namespace, plugin.name)
|
Arguments:
|
||||||
stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
|
stanza -- The class of the parent stanza.
|
||||||
stanza.plugin_tag_map[tag] = plugin
|
plugin -- The class of the plugin stanza.
|
||||||
|
"""
|
||||||
|
tag = "{%s}%s" % (plugin.namespace, plugin.name)
|
||||||
|
stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
|
||||||
|
stanza.plugin_tag_map[tag] = plugin
|
||||||
|
|
||||||
|
|
||||||
class ElementBase(object):
|
class ElementBase(object):
|
||||||
|
@ -84,7 +90,7 @@ class ElementBase(object):
|
||||||
|
|
||||||
def append(self, item):
|
def append(self, item):
|
||||||
if not isinstance(item, ElementBase):
|
if not isinstance(item, ElementBase):
|
||||||
if type(item) == xmltester:
|
if type(item) == XML_TYPE:
|
||||||
return self.appendxml(item)
|
return self.appendxml(item)
|
||||||
else:
|
else:
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
Loading…
Reference in a new issue