diff --git a/socketio/namespace.py b/socketio/namespace.py index 56ec962..c778d1e 100644 --- a/socketio/namespace.py +++ b/socketio/namespace.py @@ -75,8 +75,8 @@ class Namespace(object): if _event_name == event_name: extra_middlewares = getattr(attr, '_sio_middlewares', []) return util._apply_middlewares( - self.middlewares + extra_middlewares, event_name, - self.name, attr) + self.middlewares + extra_middlewares, event_name, + self.name, attr) @staticmethod def event_name(name): diff --git a/socketio/util.py b/socketio/util.py index 5b1f1b1..fd89ac7 100644 --- a/socketio/util.py +++ b/socketio/util.py @@ -5,6 +5,7 @@ def _copy_sio_properties(from_func, to_func): if key.startswith('_sio'): setattr(to_func, key, getattr(from_func, key)) + def _apply_middlewares(middlewares, event, namespace, handler): """Wraps the given handler with a wrapper that executes middlewares before and after the real event handler.""" @@ -43,6 +44,7 @@ def _apply_middlewares(middlewares, event, namespace, handler): return wrapped + def apply_middleware(middleware): """Returns a decorator for event handlers that adds the given middleware to the handler decorated with it.