SleekXMPP/sleekxmpp
Lance Stout 6d45971411 Allow a stanza plugin to override a parent's interfaces.
Each interface, say foo, may be overridden in three ways:
    set_foo
    get_foo
    del_foo

To declare an override in a plugin, add the class field
overrides as so:
    overrides = ['set_foo', 'del_foo']

Each override must have a matching set_foo(), etc method
for implementing the new behaviour.

To enable the overrides for a particular parent stanza,
pass the option overrides=True to register_stanza_plugin.

    register_stanza_plugin(Stanza, Plugin, overrides=True)

Example code:

class Test(ElementBase):

    name = 'test'
    namespace = 'testing'
    interfaces = set(('foo', 'bar'))
    sub_interfaces = set(('bar',))

class TestOverride(ElementBase):

    name = 'test-override'
    namespace = 'testing'
    plugin_attrib = 'override'
    interfaces = set(('foo',))
    overrides = ['set_foo']

    def setup(self, xml):
        # Don't include an XML element in the parent stanza
        # since we're adding just an attribute.
        # If adding a regular subelement, no need to do this.
        self.xml = ET.Element('')

    def set_foo(self, value):
        print("overrides!")
        self.parent()._set_attr('foo', 'override-%s' % value)

register_stanza_plugin(Test, TestOverride, overrides=True)

Example usage:
>>> t = TestStanza()
>>> t['foo'] = 'bar'
>>> t['foo']
'override-bar'
2011-03-24 12:25:17 -04:00
..
plugins Added new XEP-0050 implementation. 2011-03-24 09:35:36 -04:00
stanza Remap old method names in a better way. 2011-02-14 13:49:43 -05:00
test Allow SleekTest to wait longer when checking for sent stanzas. 2011-03-23 20:23:49 -04:00
thirdparty Fix thirdparty imports for Python3 2011-01-19 17:49:39 -05:00
xmlstream Allow a stanza plugin to override a parent's interfaces. 2011-03-24 12:25:17 -04:00
__init__.py Moved ClientXMPP to clientxmpp.py. 2010-10-06 14:20:32 -04:00
basexmpp.py Remap old method names in a better way. 2011-02-14 13:49:43 -05:00
clientxmpp.py Updated doc for connect() 2011-03-22 11:59:27 -04:00
componentxmpp.py Doesn't fail if host has NO SRV record 2010-11-09 01:53:41 +08:00
exceptions.py XMPPError exceptions can keep a stanza's contents. 2011-02-11 15:20:26 -05:00