Browse Source

TODO on EmComponent

Yann Weber 9 years ago
parent
commit
d7d4a989f1
2 changed files with 8 additions and 11 deletions
  1. 4
    4
      EditorialModel/classes.py
  2. 4
    7
      EditorialModel/components.py

+ 4
- 4
EditorialModel/classes.py View File

@@ -46,19 +46,19 @@ class EmClass(EmComponent):
46 46
     def _create_db(cls, name, class_type):
47 47
         #Create a new entry in the em_class table
48 48
         values = {'name': name, 'classtype': class_type['name'], 'icon': 0}
49
-        resclass = super(EmClass, cls).create(**values)
49
+        result = super(EmClass, cls).create(**values)
50 50
 
51
-        dbe = cls.db_engine()
51
+        dbe = result.db_engine()
52 52
         conn = dbe.connect()
53 53
 
54 54
         #Create a new table storing LodelObjects of this EmClass
55 55
         meta = sql.MetaData()
56
-        emclasstable = sql.Table(resclass.class_table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key=True))
56
+        emclasstable = sql.Table(result.class_table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key=True))
57 57
         emclasstable.create(conn)
58 58
 
59 59
         conn.close()
60 60
 
61
-        return resclass
61
+        return result
62 62
 
63 63
     @property
64 64
     ## @brief Return the table name used to stores data on this class

+ 4
- 7
EditorialModel/components.py View File

@@ -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

Loading…
Cancel
Save