Browse Source

EM: model: create a dict for each component

ArnAud 9 years ago
parent
commit
a9422795c7
1 changed files with 7 additions and 3 deletions
  1. 7
    3
      EditorialModel/model.py

+ 7
- 3
EditorialModel/model.py View File

@@ -24,6 +24,10 @@ class Model(object):
24 24
     def __init__(self, backend):
25 25
         self.backend = backend
26 26
         self.uids = {}
27
+        self.Class = {}
28
+        self.FieldGroup = {}
29
+        self.Field = {}
30
+        self.Type = {}
27 31
         self.load()
28 32
 
29 33
     ## Loads the structure of the Editorial Model
@@ -37,7 +41,8 @@ class Model(object):
37 41
             if cls:
38 42
                 component['uid'] = uid
39 43
                 self.uids[uid] = cls(component)
40
-                print (self.uids[uid])
44
+                # create a dict for each component
45
+                getattr(self, component['component'])[uid] = self.uids[uid]
41 46
         # TODO
42 47
         # iterate over classes, link to subordinates types
43 48
         # iterate over types, attach them to classes
@@ -56,5 +61,4 @@ class Model(object):
56 61
 
57 62
     ## Returns a list of all the EmClass objects of the model
58 63
     def classes(self):
59
-        classes = [component for component in self.uids.values() if isinstance(component, EmClass)]
60
-        return classes
64
+        return list(self.Class.values())

Loading…
Cancel
Save