Commit 898f5f4b authored by Lance Stout's avatar Lance Stout

Allow for registering a handler and setting it as default in one step.

parent 3ee3fdca
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment