Browse Source

[EditorialModel/fields_types.py] PEP8

Roland Haroutiounian 9 years ago
parent
commit
e0688d31b2
1 changed files with 13 additions and 12 deletions
  1. 13
    12
      EditorialModel/fields_types.py

+ 13
- 12
EditorialModel/fields_types.py View File

10
 
10
 
11
 logger = logging.getLogger('Lodel2.EditorialModel')
11
 logger = logging.getLogger('Lodel2.EditorialModel')
12
 
12
 
13
+
13
 ## Em_Field_Type (Class)
14
 ## Em_Field_Type (Class)
14
 #
15
 #
15
 # Represents an association between a field and a type
16
 # Represents an association between a field and a type
16
 class Em_Field_Type(object):
17
 class Em_Field_Type(object):
17
 
18
 
18
     table = 'em_field_type'
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
     ## __init__ (Function)
22
     ## __init__ (Function)
22
     #
23
     #
40
     # @param emField EmField: Object representing the Field
41
     # @param emField EmField: Object representing the Field
41
     # @return Em_Field_Type object
42
     # @return Em_Field_Type object
42
     @classmethod
43
     @classmethod
43
-    def create(cls, emType, emField):
44
+    def create(cls, em_type, em_field):
44
         values = {
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
     @classmethod
53
     @classmethod
53
     def _createDb(cls, **kwargs):
54
     def _createDb(cls, **kwargs):
54
-        dbe = EmComponent.getDbE()
55
+        dbe = EmComponent.db_engine()
55
         conn = dbe.connect()
56
         conn = dbe.connect()
56
         table = sqla.Table(cls.table, sqlutils.meta(dbe))
57
         table = sqla.Table(cls.table, sqlutils.meta(dbe))
57
         req = table.insert(kwargs)
58
         req = table.insert(kwargs)
68
         return self._deleteDb()
69
         return self._deleteDb()
69
 
70
 
70
     def _deleteDb(self):
71
     def _deleteDb(self):
71
-        dbe = EmComponent.getDbE()
72
+        dbe = EmComponent.db_engine()
72
         table = sqla.Table(self.table, sqlutils.meta(dbe))
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
         conn = dbe.connect()
75
         conn = dbe.connect()
75
         try:
76
         try:
76
             conn.execute(req)
77
             conn.execute(req)
95
     #
96
     #
96
     # @return True if success, False if failure
97
     # @return True if success, False if failure
97
     def _existsDb(self):
98
     def _existsDb(self):
98
-        dbe = EmComponent.getDbE()
99
+        dbe = EmComponent.db_engine()
99
         table = sqla.Table(self.table, sqlutils.meta(dbe))
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
         conn = dbe.connect()
102
         conn = dbe.connect()
102
         res = conn.execute(req).fetchall()
103
         res = conn.execute(req).fetchall()
103
         conn.close()
104
         conn.close()
104
-        return len(res)>0
105
+        return len(res) > 0

Loading…
Cancel
Save