def method_binding_meta(template, *bases):
"""Adds all bound functions from the ComponentTemplate to the class being constructed.
This returns a metaclass similar to the with_metaclass of the six library.
Args:
template (ComponentTemplate): the component config with the bound_methods attribute which we will all add
to the attributes of the to creating class.
"""
class ApplyMethodBinding(type):
def __new__(mcs, name, bases, attributes):
attributes.update(template.bound_methods)
return super(ApplyMethodBinding, mcs).__new__(mcs, name, bases, attributes)
return with_metaclass(ApplyMethodBinding, *bases)
评论列表
文章目录