1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-11-05 02:51:33 +01:00

TODO on EmComponent

This commit is contained in:
Yann 2015-07-03 09:40:31 +02:00
commit d7d4a989f1
2 changed files with 8 additions and 11 deletions

View file

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

View file

@ -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):
#<SQL>
@ -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)
#</SQL>
super(EmComponent, self).__setattr__('deleted', True)
return True
## get_max_rank