You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2014/10/21 23:11:07 UTC
svn commit: r1633464 - /qpid/proton/trunk/proton-c/bindings/python/proton.py
Author: rhs
Date: Tue Oct 21 21:11:07 2014
New Revision: 1633464
URL: http://svn.apache.org/r1633464
Log:
added dispatch utility
Modified:
qpid/proton/trunk/proton-c/bindings/python/proton.py
Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1633464&r1=1633463&r2=1633464&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/trunk/proton-c/bindings/python/proton.py Tue Oct 21 21:11:07 2014
@@ -3392,6 +3392,13 @@ class EventType:
def __repr__(self):
return self.name
+def dispatch(handler, method, *args):
+ m = getattr(handler, method, None)
+ if m:
+ return m(*args)
+ elif hasattr(handler, "on_unhandled"):
+ return handler.on_unhandled(method, args)
+
class Event:
CONNECTION_INIT = EventType(PN_CONNECTION_INIT, "on_connection_init")
@@ -3440,7 +3447,7 @@ class Event:
self.context._released()
def dispatch(self, handler):
- getattr(handler, self.type.method, handler.on_unhandled)(self)
+ return dispatch(handler, self.type.method, self)
@property
def connection(self):
@@ -3503,7 +3510,7 @@ class Event:
class Handler(object):
- def on_unhandled(self, event):
+ def on_unhandled(self, method, args):
pass
@@ -3856,6 +3863,7 @@ __all__ = [
"TransportException",
"Url",
"char",
+ "dispatch",
"symbol",
"timestamp",
"ulong"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org