summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-04-02 21:55:48 -0700
committerLance Stout <lancestout@gmail.com>2012-04-06 15:09:26 -0400
commit898f5f4b51473a60cfd4b3c699ee3d1b47b7529b (patch)
tree962afe4a7962e9f508c68374e2abb712da842772
parent3ee3fdca91a9006dc5e626c915c34258fe4834a3 (diff)
downloadslixmpp-898f5f4b51473a60cfd4b3c699ee3d1b47b7529b.tar.gz
slixmpp-898f5f4b51473a60cfd4b3c699ee3d1b47b7529b.tar.bz2
slixmpp-898f5f4b51473a60cfd4b3c699ee3d1b47b7529b.tar.xz
slixmpp-898f5f4b51473a60cfd4b3c699ee3d1b47b7529b.zip
Allow for registering a handler and setting it as default in one step.
-rw-r--r--sleekxmpp/api.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/sleekxmpp/api.py b/sleekxmpp/api.py
index 9d8ec201..82ff8ae7 100644
--- a/sleekxmpp/api.py
+++ b/sleekxmpp/api.py
@@ -14,9 +14,9 @@ class APIWrapper(object):
elif attr == 'settings':
return self.api.settings[self.name]
elif attr == 'register':
- def curried_handler(handler, op, jid=None, node=None):
+ def curried_handler(handler, op, jid=None, node=None, default=False):
register = getattr(self.api, attr)
- return register(handler, self.name, op, jid, node)
+ return register(handler, self.name, op, jid, node, default)
return curried_handler
elif attr == 'register_default':
def curried_handler(handler, op, jid=None, node=None):
@@ -153,6 +153,9 @@ class APIRegistry(object):
else:
self._handlers[ctype][op]['node'][(jid, node)] = handler
+ if default:
+ self.register_default(handler, ctype, op)
+
def register_default(self, handler, ctype, op):
"""Register a default, global handler for an operation.