From edd8ac2d77b747cffbcf702e71f2633a148d64c6 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Tue, 15 Jul 2014 16:09:11 +1000 Subject: [PATCH] Return the function again from the hook decorator The decorator variant of hook registration did not return anything, meaning that the decorated function would end up being `None`. This was not noticed, as the functions are rarely called manually, as opposed to being invoked via the hook. --- wagtail/wagtailcore/hooks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wagtail/wagtailcore/hooks.py b/wagtail/wagtailcore/hooks.py index b6d13bf11..958675b97 100644 --- a/wagtail/wagtailcore/hooks.py +++ b/wagtail/wagtailcore/hooks.py @@ -25,7 +25,10 @@ def register(hook_name, fn=None): # Pretend to be a decorator if fn is not supplied if fn is None: - return lambda fn: register(hook_name, fn) + def decorator(fn): + register(hook_name, fn) + return fn + return decorator if hook_name not in _hooks: _hooks[hook_name] = []