You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
582 B

def apply_interceptor(interceptor):
"""Returns a decorator for event handlers that adds the given
interceptor to the handler decorated with it.
:param interceptor: The interceptor to add
Ensure that you only add well-behaving decorators after this one
(meaning such that preserve attributes) because you'll loose them
otherwise.
"""
def wrapper(handler):
if not hasattr(handler, '_sio_interceptors'):
handler._sio_interceptors = []
handler._sio_interceptors.append(interceptor)
return handler
return wrapper