diff options
author | Lance Stout <lancestout@gmail.com> | 2013-02-25 09:53:35 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2013-02-25 09:53:35 -0800 |
commit | 82bbe5d1a67613d5e1a23bec4260b9e6644d339b (patch) | |
tree | 2d7a61c4f64afc7485e5a6ae71b0fe972ab8d1e4 | |
parent | 9a45ebd98bb03120f1eca3945eaa8777abe8ece0 (diff) | |
parent | a1d71d31e85df2cf6efc835c30592126ca9861f2 (diff) | |
download | slixmpp-82bbe5d1a67613d5e1a23bec4260b9e6644d339b.tar.gz slixmpp-82bbe5d1a67613d5e1a23bec4260b9e6644d339b.tar.bz2 slixmpp-82bbe5d1a67613d5e1a23bec4260b9e6644d339b.tar.xz slixmpp-82bbe5d1a67613d5e1a23bec4260b9e6644d339b.zip |
Merge branch 'develop'
-rw-r--r-- | docs/create_plugin.rst | 4 | ||||
-rwxr-xr-x | examples/custom_stanzas/custom_stanza_provider.py | 2 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0009/rpc.py | 6 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0030/stanza/items.py | 7 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0045.py | 10 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0202/time.py | 2 | ||||
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 4 | ||||
-rw-r--r-- | tests/test_stream_handlers.py | 8 |
8 files changed, 22 insertions, 21 deletions
diff --git a/docs/create_plugin.rst b/docs/create_plugin.rst index 12efa84c..2b0514b8 100644 --- a/docs/create_plugin.rst +++ b/docs/create_plugin.rst @@ -222,7 +222,7 @@ handler function to process registration requests. self.description = "In-Band Registration" self.xep = "0077" - self.xmpp.registerHandler( + self.xmpp.register_handler( Callback('In-Band Registration', MatchXPath('{%s}iq/{jabber:iq:register}query' % self.xmpp.default_ns), self.__handleRegistration)) @@ -601,7 +601,7 @@ with some additional registration fields implemented. self.form_instructions = "" self.backend = UserStore() - self.xmpp.registerHandler( + self.xmpp.register_handler( Callback('In-Band Registration', MatchXPath('{%s}iq/{jabber:iq:register}query' % self.xmpp.default_ns), self.__handleRegistration)) diff --git a/examples/custom_stanzas/custom_stanza_provider.py b/examples/custom_stanzas/custom_stanza_provider.py index b0e00247..0ebdb77e 100755 --- a/examples/custom_stanzas/custom_stanza_provider.py +++ b/examples/custom_stanzas/custom_stanza_provider.py @@ -51,7 +51,7 @@ class ActionBot(sleekxmpp.ClientXMPP): # our roster. self.add_event_handler("session_start", self.start) - self.registerHandler( + self.register_handler( Callback('Some custom iq', StanzaPath('iq@type=set/action'), self._handle_action)) diff --git a/sleekxmpp/plugins/xep_0009/rpc.py b/sleekxmpp/plugins/xep_0009/rpc.py index 4e1c538b..3378c650 100644 --- a/sleekxmpp/plugins/xep_0009/rpc.py +++ b/sleekxmpp/plugins/xep_0009/rpc.py @@ -32,15 +32,15 @@ class XEP_0009(BasePlugin): register_stanza_plugin(RPCQuery, MethodCall)
register_stanza_plugin(RPCQuery, MethodResponse)
- self.xmpp.registerHandler(
+ self.xmpp.register_handler(
Callback('RPC Call', MatchXPath('{%s}iq/{%s}query/{%s}methodCall' % (self.xmpp.default_ns, RPCQuery.namespace, RPCQuery.namespace)),
self._handle_method_call)
)
- self.xmpp.registerHandler(
+ self.xmpp.register_handler(
Callback('RPC Call', MatchXPath('{%s}iq/{%s}query/{%s}methodResponse' % (self.xmpp.default_ns, RPCQuery.namespace, RPCQuery.namespace)),
self._handle_method_response)
)
- self.xmpp.registerHandler(
+ self.xmpp.register_handler(
Callback('RPC Call', MatchXPath('{%s}iq/{%s}error' % (self.xmpp.default_ns, self.xmpp.default_ns)),
self._handle_error)
)
diff --git a/sleekxmpp/plugins/xep_0030/stanza/items.py b/sleekxmpp/plugins/xep_0030/stanza/items.py index 512f2336..10458614 100644 --- a/sleekxmpp/plugins/xep_0030/stanza/items.py +++ b/sleekxmpp/plugins/xep_0030/stanza/items.py @@ -128,9 +128,10 @@ class DiscoItems(ElementBase): def del_items(self): """Remove all items.""" self._items = set() - for item in self['substanzas']: - if isinstance(item, DiscoItem): - self.xml.remove(item.xml) + items = [i for i in self.iterables if isinstance(i, DiscoItem)] + for item in items: + self.xml.remove(item.xml) + self.iterables.remove(item) class DiscoItem(ElementBase): diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py index b823e76d..1d5f3c83 100644 --- a/sleekxmpp/plugins/xep_0045.py +++ b/sleekxmpp/plugins/xep_0045.py @@ -125,11 +125,11 @@ class XEP_0045(BasePlugin): self.xep = '0045' # load MUC support in presence stanzas register_stanza_plugin(Presence, MUCPresence) - self.xmpp.registerHandler(Callback('MUCPresence', MatchXMLMask("<presence xmlns='%s' />" % self.xmpp.default_ns), self.handle_groupchat_presence)) - self.xmpp.registerHandler(Callback('MUCMessage', MatchXMLMask("<message xmlns='%s' type='groupchat'><body/></message>" % self.xmpp.default_ns), self.handle_groupchat_message)) - self.xmpp.registerHandler(Callback('MUCSubject', MatchXMLMask("<message xmlns='%s' type='groupchat'><subject/></message>" % self.xmpp.default_ns), self.handle_groupchat_subject)) - self.xmpp.registerHandler(Callback('MUCConfig', MatchXMLMask("<message xmlns='%s' type='groupchat'><x xmlns='http://jabber.org/protocol/muc#user'><status/></x></message>" % self.xmpp.default_ns), self.handle_config_change)) - self.xmpp.registerHandler(Callback('MUCInvite', MatchXPath("{%s}message/{%s}x/{%s}invite" % ( + self.xmpp.register_handler(Callback('MUCPresence', MatchXMLMask("<presence xmlns='%s' />" % self.xmpp.default_ns), self.handle_groupchat_presence)) + self.xmpp.register_handler(Callback('MUCMessage', MatchXMLMask("<message xmlns='%s' type='groupchat'><body/></message>" % self.xmpp.default_ns), self.handle_groupchat_message)) + self.xmpp.register_handler(Callback('MUCSubject', MatchXMLMask("<message xmlns='%s' type='groupchat'><subject/></message>" % self.xmpp.default_ns), self.handle_groupchat_subject)) + self.xmpp.register_handler(Callback('MUCConfig', MatchXMLMask("<message xmlns='%s' type='groupchat'><x xmlns='http://jabber.org/protocol/muc#user'><status/></x></message>" % self.xmpp.default_ns), self.handle_config_change)) + self.xmpp.register_handler(Callback('MUCInvite', MatchXPath("{%s}message/{%s}x/{%s}invite" % ( self.xmpp.default_ns, 'http://jabber.org/protocol/muc#user', 'http://jabber.org/protocol/muc#user')), self.handle_groupchat_invite)) diff --git a/sleekxmpp/plugins/xep_0202/time.py b/sleekxmpp/plugins/xep_0202/time.py index fe20449d..d5b3af37 100644 --- a/sleekxmpp/plugins/xep_0202/time.py +++ b/sleekxmpp/plugins/xep_0202/time.py @@ -48,7 +48,7 @@ class XEP_0202(BasePlugin): self.local_time = default_local_time
- self.xmpp.registerHandler(
+ self.xmpp.register_handler(
Callback('Entity Time',
StanzaPath('iq/entity_time'),
self._handle_time_request))
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 3f87df52..289e3a21 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -1015,8 +1015,8 @@ class XMLStream(object): # and handler classes here. if name is None: - name = 'add_handler_%s' % self.getNewId() - self.registerHandler(XMLCallback(name, MatchXMLMask(mask), pointer, + name = 'add_handler_%s' % self.new_id() + self.register_handler(XMLCallback(name, MatchXMLMask(mask), pointer, once=disposable, instream=instream)) def register_handler(self, handler, before=None, after=None): diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py index d3850a94..183e4bf9 100644 --- a/tests/test_stream_handlers.py +++ b/tests/test_stream_handlers.py @@ -21,7 +21,7 @@ class TestHandlers(SleekTest): """Test using stream callback handlers.""" def callback_handler(stanza): - self.xmpp.sendRaw(""" + self.xmpp.send_raw(""" <message> <body>Success!</body> </message> @@ -31,7 +31,7 @@ class TestHandlers(SleekTest): MatchXPath('{test}tester'), callback_handler) - self.xmpp.registerHandler(callback) + self.xmpp.register_handler(callback) self.recv("""<tester xmlns="test" />""") @@ -49,7 +49,7 @@ class TestHandlers(SleekTest): iq['query'] = 'test' reply = iq.send(block=True) if reply: - self.xmpp.sendRaw(""" + self.xmpp.send_raw(""" <message> <body>Successful: %s</body> </message> @@ -112,7 +112,7 @@ class TestHandlers(SleekTest): time.sleep(0.1) # Check that the waiter is no longer registered - waiter_exists = self.xmpp.removeHandler('IqWait_test2') + waiter_exists = self.xmpp.remove_handler('IqWait_test2') self.failUnless(waiter_exists == False, "Waiter handler was not removed.") |