G
gentlestone
Hi, is there some well-known problems with class method monkey
patching?
I've got this error message:
unbound method get_pocet_neocislovanych() must be called with Pozemok
instance as first argument (got Subjekt instance instead)
The method is declared as:
@classmethod
@monkeypatch(Dokument)
def get_pocet_neocislovanych(cls, subjekt):
return cls.objects.filter(subjekt = subjekt, cislo__isnull =
True).count() # or pass, this line is not important
and the monkey patch decorator is declared as:
def monkeypatch(cls):
def decorator(func):
setattr(cls, func.__name__, func)
return func
return decorator
If I move the method to class declaration (whitout monkey patching),
everything is ok, but only if I've restarted the server.
patching?
I've got this error message:
unbound method get_pocet_neocislovanych() must be called with Pozemok
instance as first argument (got Subjekt instance instead)
The method is declared as:
@classmethod
@monkeypatch(Dokument)
def get_pocet_neocislovanych(cls, subjekt):
return cls.objects.filter(subjekt = subjekt, cislo__isnull =
True).count() # or pass, this line is not important
and the monkey patch decorator is declared as:
def monkeypatch(cls):
def decorator(func):
setattr(cls, func.__name__, func)
return func
return decorator
If I move the method to class declaration (whitout monkey patching),
everything is ok, but only if I've restarted the server.