From 285c955921744873a3955091b09baf0c710ad58f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 20 May 2013 01:53:10 +0100 Subject: Added an explanation for how with_metaclass works --- jinja2/_compat.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jinja2/_compat.py b/jinja2/_compat.py index 5d4fba5..2a0e6ed 100644 --- a/jinja2/_compat.py +++ b/jinja2/_compat.py @@ -82,6 +82,15 @@ except NameError: def with_metaclass(meta, *bases): + # This requires a bit of explanation: the basic idea is to make a + # dummy metaclass for one level of class instanciation that replaces + # itself with the actual metaclass. Because of internal type checks + # we also need to make sure that we downgrade the custom metaclass + # for one level to something closer to type (that's why __call__ and + # __init__ comes back from type etc.). + # + # This has the advantage over six.with_metaclass in that it does not + # introduce dummy classes into the final MRO. class __metaclass__(meta): __call__ = type.__call__ __init__ = type.__init__ -- cgit v1.2.1