|
@@ -147,7 +147,16 @@ class Model(object):
|
147
|
147
|
em_component.init_ended()
|
148
|
148
|
|
149
|
149
|
#register the creation in migration handler
|
150
|
|
- self.migration_handler.register_change(em_component.uid, None, em_component.attr_dump)
|
|
150
|
+ try:
|
|
151
|
+ self.migration_handler.register_change(em_component.uid, None, em_component.attr_dump)
|
|
152
|
+ except MigrationHandlerChangeError as e:
|
|
153
|
+ #Revert the creation
|
|
154
|
+ self.components(em_component.__class__).remove(em_component)
|
|
155
|
+ del self._components['uids'][em_component.uid]
|
|
156
|
+ print(self._components)
|
|
157
|
+ raise e
|
|
158
|
+
|
|
159
|
+ self.migration_handler.register_model_state(hash(self))
|
151
|
160
|
|
152
|
161
|
return em_component
|
153
|
162
|
|
|
@@ -166,6 +175,8 @@ class Model(object):
|
166
|
175
|
if em_component.delete_check():
|
167
|
176
|
self._components[self.name_from_emclass(em_component.__class__)].remove(em_component)
|
168
|
177
|
del self._components['uids'][uid]
|
|
178
|
+ #Register the new EM state
|
|
179
|
+ self.migration_handler.register_model_state(hash(self))
|
169
|
180
|
return True
|
170
|
181
|
|
171
|
182
|
## Changes the current backend
|