|
@@ -10,13 +10,14 @@ import logging
|
10
|
10
|
|
11
|
11
|
logger = logging.getLogger('Lodel2.EditorialModel')
|
12
|
12
|
|
|
13
|
+
|
13
|
14
|
## Em_Field_Type (Class)
|
14
|
15
|
#
|
15
|
16
|
# Represents an association between a field and a type
|
16
|
17
|
class Em_Field_Type(object):
|
17
|
18
|
|
18
|
19
|
table = 'em_field_type'
|
19
|
|
- _fields = [('type_id', EmField_integer),('field_id', EmField_integer)]
|
|
20
|
+ _fields = [('type_id', EmField_integer), ('field_id', EmField_integer)]
|
20
|
21
|
|
21
|
22
|
## __init__ (Function)
|
22
|
23
|
#
|
|
@@ -40,18 +41,18 @@ class Em_Field_Type(object):
|
40
|
41
|
# @param emField EmField: Object representing the Field
|
41
|
42
|
# @return Em_Field_Type object
|
42
|
43
|
@classmethod
|
43
|
|
- def create(cls, emType, emField):
|
|
44
|
+ def create(cls, em_type, em_field):
|
44
|
45
|
values = {
|
45
|
|
- 'type_id': emType.uid,
|
46
|
|
- 'field_id': emField.uid
|
|
46
|
+ 'type_id': em_type.uid,
|
|
47
|
+ 'field_id': em_field.uid
|
47
|
48
|
}
|
48
|
49
|
|
49
|
|
- createdRelation = Em_Field_Type._createDb(**values)
|
50
|
|
- return createdRelation
|
|
50
|
+ created_relation = Em_Field_Type._createDb(**values)
|
|
51
|
+ return created_relation
|
51
|
52
|
|
52
|
53
|
@classmethod
|
53
|
54
|
def _createDb(cls, **kwargs):
|
54
|
|
- dbe = EmComponent.getDbE()
|
|
55
|
+ dbe = EmComponent.db_engine()
|
55
|
56
|
conn = dbe.connect()
|
56
|
57
|
table = sqla.Table(cls.table, sqlutils.meta(dbe))
|
57
|
58
|
req = table.insert(kwargs)
|
|
@@ -68,9 +69,9 @@ class Em_Field_Type(object):
|
68
|
69
|
return self._deleteDb()
|
69
|
70
|
|
70
|
71
|
def _deleteDb(self):
|
71
|
|
- dbe = EmComponent.getDbE()
|
|
72
|
+ dbe = EmComponent.db_engine()
|
72
|
73
|
table = sqla.Table(self.table, sqlutils.meta(dbe))
|
73
|
|
- req = table.delete().where(table.c.type_id==self.type_id).where(table.c.field_id==self.field_id)
|
|
74
|
+ req = table.delete().where(table.c.type_id == self.type_id).where(table.c.field_id == self.field_id)
|
74
|
75
|
conn = dbe.connect()
|
75
|
76
|
try:
|
76
|
77
|
conn.execute(req)
|
|
@@ -95,10 +96,10 @@ class Em_Field_Type(object):
|
95
|
96
|
#
|
96
|
97
|
# @return True if success, False if failure
|
97
|
98
|
def _existsDb(self):
|
98
|
|
- dbe = EmComponent.getDbE()
|
|
99
|
+ dbe = EmComponent.db_engine()
|
99
|
100
|
table = sqla.Table(self.table, sqlutils.meta(dbe))
|
100
|
|
- req = table.select().where(table.c.type_id==self.type_id).where(table.c.field_id==self.field_id)
|
|
101
|
+ req = table.select().where(table.c.type_id == self.type_id).where(table.c.field_id == self.field_id)
|
101
|
102
|
conn = dbe.connect()
|
102
|
103
|
res = conn.execute(req).fetchall()
|
103
|
104
|
conn.close()
|
104
|
|
- return len(res)>0
|
|
105
|
+ return len(res) > 0
|