slixmpp/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
xmlstream Allow a stanza plugin to override a parent's interfaces. 2011-03-24 12:25:17 -04:00
__init__.py
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
exceptions.py