I have a ReportEntry class
class ReportEntry(object):
def __init__(self):
# Many attributes defined here
... # Lot many setattr/getattr here
def validate(self):
# Lot of validation code in here
return self
Multiple other classes maintain has-a relation with ReportEntry class
class A(object):
def test1(self):
t1 = ReportEntry()
# Assign the attribute values to t1
return t1.validate()
def test2(self):
t2 = ReportEntry()
# Assign the attribute values to t2
return t2.validate()
And there are multiple such classes as A.
I need to enforce each ReportEntry class instance to call validate() on return or maybe just before return.
Basically, no instance of ReportEntry should escape validation since the final report generation will fail if something is missing.
How may I achieve that ?