mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-26 03:00:14 +00:00
6d45971411
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' |
||
---|---|---|
.. | ||
__init__.py | ||
live_multiple_streams.py | ||
live_test.py | ||
test_events.py | ||
test_jid.py | ||
test_stanza_base.py | ||
test_stanza_element.py | ||
test_stanza_error.py | ||
test_stanza_gmail.py | ||
test_stanza_iq.py | ||
test_stanza_message.py | ||
test_stanza_presence.py | ||
test_stanza_roster.py | ||
test_stanza_xep_0004.py | ||
test_stanza_xep_0009.py | ||
test_stanza_xep_0030.py | ||
test_stanza_xep_0033.py | ||
test_stanza_xep_0050.py | ||
test_stanza_xep_0059.py | ||
test_stanza_xep_0060.py | ||
test_stanza_xep_0085.py | ||
test_stream.py | ||
test_stream_exceptions.py | ||
test_stream_handlers.py | ||
test_stream_presence.py | ||
test_stream_roster.py | ||
test_stream_xep_0030.py | ||
test_stream_xep_0050.py | ||
test_stream_xep_0059.py | ||
test_stream_xep_0085.py | ||
test_stream_xep_0092.py | ||
test_stream_xep_0128.py | ||
test_stream_xep_0249.py | ||
test_tostring.py |