From d7d4a989f10dd9aea21e98e8601e20dfb7a17754 Mon Sep 17 00:00:00 2001 From: Yann Date: Fri, 3 Jul 2015 09:40:31 +0200 Subject: [PATCH] TODO on EmComponent --- EditorialModel/classes.py | 8 ++++---- EditorialModel/components.py | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/EditorialModel/classes.py b/EditorialModel/classes.py index dfbb939..c2aba3e 100644 --- a/EditorialModel/classes.py +++ b/EditorialModel/classes.py @@ -46,19 +46,19 @@ class EmClass(EmComponent): def _create_db(cls, name, class_type): #Create a new entry in the em_class table values = {'name': name, 'classtype': class_type['name'], 'icon': 0} - resclass = super(EmClass, cls).create(**values) + result = super(EmClass, cls).create(**values) - dbe = cls.db_engine() + dbe = result.db_engine() conn = dbe.connect() #Create a new table storing LodelObjects of this EmClass meta = sql.MetaData() - emclasstable = sql.Table(resclass.class_table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key=True)) + emclasstable = sql.Table(result.class_table_name, meta, sql.Column('uid', sql.VARCHAR(50), primary_key=True)) emclasstable.create(conn) conn.close() - return resclass + return result @property ## @brief Return the table name used to stores data on this class diff --git a/EditorialModel/components.py b/EditorialModel/components.py index f3247b5..5f76544 100644 --- a/EditorialModel/components.py +++ b/EditorialModel/components.py @@ -164,9 +164,7 @@ class EmComponent(object): # @return An instance of the created component # @throw TypeError if an element of kwargs isn't a valid object propertie or if a mandatory argument is missing # @throw RuntimeError if the creation fails at database level - # @todo Check that the query didn't failed # @todo Check that every mandatory _fields are given in args - # @todo Put a real rank at creation # @todo Stop using datetime.datetime.utcnow() for date_update and date_create init @classmethod def create(cls, **kwargs): @@ -190,8 +188,8 @@ class EmComponent(object): return exist except EmComponentNotExistError: pass - - #TODO check that every mandatory _fields are here like below for example + + # Mandatory fields check (actual fieldtypes don't allow this check #for name in cls._fields: # if cls._fields[name].notNull and cls._fields[name].default == None: # raise TypeError("Missing argument : "+name) @@ -210,7 +208,7 @@ class EmComponent(object): if not conn.execute(req): raise RuntimeError("Unable to create the "+cls.__class__.__name__+" EmComponent ") conn.close() - return cls(kwargs['name']) # Maybe no need to check res because this would fail if the query failed + return cls(kwargs['name']) ## Write the representation of the component in the database # @return bool @@ -246,7 +244,6 @@ class EmComponent(object): ## Delete this component data in the database # @return bool : True if deleted False if deletion aborded - # @todo Use something like __del__ instead (or call it at the end) # @throw RunTimeError if it was unable to do the deletion def delete(self): # @@ -259,8 +256,8 @@ class EmComponent(object): if not res: raise RuntimeError("Unable to delete the component in the database") - super(EmComponent, self).__setattr__('deleted', True) # + super(EmComponent, self).__setattr__('deleted', True) return True ## get_max_rank