I have a base class, in which I want to define a decorator. That decorator should be used in inheriting classes.
class Upper(object):
def model_definition(self, name):
def func(create_function):
if self.loading:
model = self.load(name)
else:
model = create_function()
self.models[name] = model
return model
return func
class Lower(Upper):
@Upper.model_definition(name='example_model'):
def define_model(self):
[...]
return model
When doing it like this, I'm getting the message model_definition() missing 1 required positional argument: 'self'
. What is the correct way to do it?