|
@@ -61,8 +61,7 @@ class Model(object):
|
61
|
61
|
# @todo réécrire le split, c'est pas bô
|
62
|
62
|
def name_from_emclass(em_class):
|
63
|
63
|
if em_class not in Model.components_class:
|
64
|
|
- spl = em_class.__module__.split('.')
|
65
|
|
- if spl[1] == 'fieldtypes':
|
|
64
|
+ if issubclass(em_class, EmField):
|
66
|
65
|
return 'EmField'
|
67
|
66
|
return False
|
68
|
67
|
return em_class.__name__
|
|
@@ -154,7 +153,12 @@ class Model(object):
|
154
|
153
|
# @todo Handle a raise from the migration handler
|
155
|
154
|
# @todo Transform the datas arg in **datas ?
|
156
|
155
|
def create_component(self, component_type, datas, uid=None):
|
157
|
|
- if component_type == 'EmField':
|
|
156
|
+ if not (uid is None) and (not isinstance(uid, int) or uid <= 0 or uid in self._components['uids']):
|
|
157
|
+ raise ValueError("Invalid uid provided")
|
|
158
|
+
|
|
159
|
+ if component_type not in [ n for n in self._components.keys() if n != 'uids' ]:
|
|
160
|
+ raise ValueError("Invalid component_type rpovided")
|
|
161
|
+ elif component_type == 'EmField':
|
158
|
162
|
#special process for EmField
|
159
|
163
|
if not 'fieldtype' in datas:
|
160
|
164
|
raise AttributeError("Missing 'fieldtype' from EmField instanciation")
|