qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [25/50] [abbrv] qpid-proton git commit: added dispatch utility
Date Fri, 14 Nov 2014 11:03:34 GMT
added dispatch utility

git-svn-id: https://svn.apache.org/repos/asf/qpid/proton/trunk@1633464 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/dc44e837
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/dc44e837
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/dc44e837

Branch: refs/heads/examples
Commit: dc44e837da29a5863ec3685cf7f13506feb6050e
Parents: 719ee5b
Author: Rafael H. Schloming <rhs@apache.org>
Authored: Tue Oct 21 21:11:07 2014 +0000
Committer: Rafael H. Schloming <rhs@apache.org>
Committed: Tue Oct 21 21:11:07 2014 +0000

----------------------------------------------------------------------
 proton-c/bindings/python/proton.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dc44e837/proton-c/bindings/python/proton.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton.py b/proton-c/bindings/python/proton.py
index 84b6654..862b673 100644
--- a/proton-c/bindings/python/proton.py
+++ b/proton-c/bindings/python/proton.py
@@ -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


Mime
View raw message