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:
vecāks
1b3565d890
iesūtījums
d2f6509397
1 izmainītas datnes ar 4 papildinājumiem un 2 izdzēšanām
|
|
@ -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)
|
||||
|
|
|
|||
Notiek ielāde…
Pievienot tabulu
Pievienot saiti
Atsaukties jaunā pieteikumā