|
@@ -164,9 +164,7 @@ class EmComponent(object):
|
164
|
164
|
# @return An instance of the created component
|
165
|
165
|
# @throw TypeError if an element of kwargs isn't a valid object propertie or if a mandatory argument is missing
|
166
|
166
|
# @throw RuntimeError if the creation fails at database level
|
167
|
|
- # @todo Check that the query didn't failed
|
168
|
167
|
# @todo Check that every mandatory _fields are given in args
|
169
|
|
- # @todo Put a real rank at creation
|
170
|
168
|
# @todo Stop using datetime.datetime.utcnow() for date_update and date_create init
|
171
|
169
|
@classmethod
|
172
|
170
|
def create(cls, **kwargs):
|
|
@@ -190,8 +188,8 @@ class EmComponent(object):
|
190
|
188
|
return exist
|
191
|
189
|
except EmComponentNotExistError:
|
192
|
190
|
pass
|
193
|
|
-
|
194
|
|
- #TODO check that every mandatory _fields are here like below for example
|
|
191
|
+
|
|
192
|
+ # Mandatory fields check (actual fieldtypes don't allow this check
|
195
|
193
|
#for name in cls._fields:
|
196
|
194
|
# if cls._fields[name].notNull and cls._fields[name].default == None:
|
197
|
195
|
# raise TypeError("Missing argument : "+name)
|
|
@@ -210,7 +208,7 @@ class EmComponent(object):
|
210
|
208
|
if not conn.execute(req):
|
211
|
209
|
raise RuntimeError("Unable to create the "+cls.__class__.__name__+" EmComponent ")
|
212
|
210
|
conn.close()
|
213
|
|
- return cls(kwargs['name']) # Maybe no need to check res because this would fail if the query failed
|
|
211
|
+ return cls(kwargs['name'])
|
214
|
212
|
|
215
|
213
|
## Write the representation of the component in the database
|
216
|
214
|
# @return bool
|
|
@@ -246,7 +244,6 @@ class EmComponent(object):
|
246
|
244
|
|
247
|
245
|
## Delete this component data in the database
|
248
|
246
|
# @return bool : True if deleted False if deletion aborded
|
249
|
|
- # @todo Use something like __del__ instead (or call it at the end)
|
250
|
247
|
# @throw RunTimeError if it was unable to do the deletion
|
251
|
248
|
def delete(self):
|
252
|
249
|
#<SQL>
|
|
@@ -259,8 +256,8 @@ class EmComponent(object):
|
259
|
256
|
if not res:
|
260
|
257
|
raise RuntimeError("Unable to delete the component in the database")
|
261
|
258
|
|
262
|
|
- super(EmComponent, self).__setattr__('deleted', True)
|
263
|
259
|
#</SQL>
|
|
260
|
+ super(EmComponent, self).__setattr__('deleted', True)
|
264
|
261
|
return True
|
265
|
262
|
|
266
|
263
|
## get_max_rank
|