Commit 328cd14f authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update classes defining the model to replace the method create by a constructor.

parent 33868299
......@@ -13,34 +13,16 @@ from pydal import Field
class EvtModelCore(object):
"""The core tables.
"""Create the history table and its foreign tables, including
alias table for object and people categories.
"""
@staticmethod
def _protect(table):
"""protect the content of the table.
* Record containing the UNDEF string can not be update or delete.
* Inhibit cascade delte for foreign elements
Args:
table (pyDAL.Table): database table
Args:
db (pyDAL.DAL): database connection
T (): language translator
"""
table._before_delete.append(INHIBIT_CASCADE_DELETE)
table._before_delete.append(dbui.INHIBIT_DELETE_UNDEF)
table._before_update.append(dbui.INHIBIT_UPDATE_UNDEF)
@staticmethod
def create(db, T):
"""Create all tables belonging to the core, including
alias table for object and people categories.
Args:
db (pyDAL.DAL): database connection
T (): language translator
"""
def __init__(self, db, T):
"""
# foreign tables
EvtModelCore.domains(db, T)
EvtModelCore.events(db, T)
......@@ -59,6 +41,21 @@ class EvtModelCore(object):
db.object_categories.with_alias("alias_object_categories")
db.people_categories.with_alias("alias_people_categories")
@staticmethod
def _protect(table):
"""protect the content of the table.
* Record containing the UNDEF string can not be update or delete.
* Inhibit cascade delte for foreign elements
Args:
table (pyDAL.Table): database table
"""
table._before_delete.append(INHIBIT_CASCADE_DELETE)
table._before_delete.append(dbui.INHIBIT_DELETE_UNDEF)
table._before_update.append(dbui.INHIBIT_UPDATE_UNDEF)
@staticmethod
def domains(db, T):
"""domains table
......
......@@ -78,18 +78,16 @@ TP_SORTERS = \
class EvtModelReport(object):
"""The report tables.
"""Create the tables for the reporting: lists, metrics1d, metrics2d,
and graphs.
"""
@staticmethod
def create(db, T):
"""Create all the tables for reporting.
Args:
db (pyDAL.DAL): database connection
T (): language translator
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
def __init__(self, db, T):
"""
EvtModelReport.graphs(db, T)
EvtModelReport.lists(db, T)
EvtModelReport.metrics1d(db, T)
......
......@@ -12,19 +12,16 @@ TP_DATA = "The field history.data contains the given value."
class EvtModelSelector(object):
"""The selector tables.
"""Create the table defining the selector.
"""
@staticmethod
def create(virtdb, db, T):
"""Create all the tables for selector.
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): database connection
T (): language translator
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
def __init__(self, virtdb, db, T):
"""
EvtModelSelector.selector(virtdb, db, T)
@staticmethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment