I would like the __init__ and populate methods ref, to have the following signature:
def __init__(self, throw_on_unknown_keyword = False, **kwargs):
# ...
def populate(self, throw_on_unknown_keyword = False, **values):
# ...
if structure_name in values:
field.__set__(self, values.pop(structure_name))
elif throw_on_unknown_keyword and structure_name != 'throw_on_unknown_keyword' :
throw # ...
for name, _, field in fields:
if name in values:
field.__set__(self, values.pop(name))
elif throw_on_unknown_keyword and name != 'throw_on_unknown_keyword':
throw # ...
# warning: I have not checked the details!
Reason: I wrap the Model inside a class:
class A:
class ModelA(models.Base):
a = fields.DateTimeField(required=True)
b = fields.FloatField(required=True)
c = fields.FloatField(required=True)
def __init__(self, **kwargs):
self.model = self.ModelA(throw_on_unknown_keyword = True, **kwargs)
# #Instead of
#def __init__(self, a, b, c):
# self.model = self.ModelA(a = a, b = b, c = c)
With throw_on_unknown_keyword = True, I keep the constructor of A and the model synchronized, and get an exception if they are not synchronized.
Hi,
I would like the
__init__
andpopulate
methods ref, to have the following signature:Reason: I wrap the Model inside a class:
With
throw_on_unknown_keyword = True
, I keep the constructor of A and the model synchronized, and get an exception if they are not synchronized.Is that feasible?