From d9c1559a909169cc33f04ff4a99a6c06163418a9 Mon Sep 17 00:00:00 2001 From: AlexejStukov Date: Thu, 21 Jul 2016 08:18:15 +0200 Subject: [PATCH 1/2] Register Bindings if they are declared after ready has run If the declaration of a binding happens after the ``ready``-method of channels has run, the binding was not registered. With this it will be registered at declaration. This also ensures that no registration happens before the ``ready``-method runs. --- channels/binding/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/channels/binding/base.py b/channels/binding/base.py index 9abbce6..f0b2dce 100644 --- a/channels/binding/base.py +++ b/channels/binding/base.py @@ -12,19 +12,23 @@ class BindingMetaclass(type): """ Metaclass that tracks instantiations of its type. """ - + + register_immediately = False binding_classes = [] def __new__(cls, name, bases, body): klass = type.__new__(cls, name, bases, body) if bases != (object, ): cls.binding_classes.append(klass) + if cls.register_immediately: + cls.register() return klass @classmethod def register_all(cls): for binding_class in cls.binding_classes: binding_class.register() + cls.register_immediately = True @six.add_metaclass(BindingMetaclass) From bf5b9d31a008224a299a6a3b9a6703cd0d861113 Mon Sep 17 00:00:00 2001 From: AlexejStukov Date: Thu, 21 Jul 2016 08:28:06 +0200 Subject: [PATCH 2/2] removed whitespace in blank line --- channels/binding/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channels/binding/base.py b/channels/binding/base.py index f0b2dce..c57fa18 100644 --- a/channels/binding/base.py +++ b/channels/binding/base.py @@ -12,7 +12,7 @@ class BindingMetaclass(type): """ Metaclass that tracks instantiations of its type. """ - + register_immediately = False binding_classes = []