1
0
Atzarojums 0
spoguļota no https://github.com/yweber/lodel2.git sinhronizēta 2025-12-18 07:46:54 +01:00

Checking type of model argument (without importing Model)

The check is done on the __class__.__name__ attr of model argument (maybe not a good solution ?)
Šis iesūtījums ir iekļauts:
Yann 2015-08-28 09:49:54 +02:00
vecāks 1b3565d890
iesūtījums d2f6509397

Apskatīt datni

@ -28,8 +28,10 @@ class EmComponent(object):
def __init__(self, model, uid, name, string = None, help_text = None, date_update = None, date_create = None, rank = None):
if type(self) == EmComponent:
raise NotImplementedError('Abstract class')
self.model = model # AHAH cannot check type without importing Model ?
if model.__class__.__name__ != 'Model':
raise TypeError("Excepted type for 'model' arg is <class 'Model'> but got {} instead".format(type(model)))
self.model = model
self.uid = uid
self.check_type('uid', int)