Browse Source

EM: store in each component a reference to the list of the other

ArnAud 9 years ago
parent
commit
79336030c7
2 changed files with 3 additions and 2 deletions
  1. 2
    1
      EditorialModel/components.py
  2. 1
    1
      EditorialModel/model.py

+ 2
- 1
EditorialModel/components.py View File

@@ -45,7 +45,7 @@ class EmComponent(object):
45 45
     # @param id_or_name int|str: name or id of the object
46 46
     # @throw TypeError if id_or_name is not an integer nor a string
47 47
     # @throw NotImplementedError if called with EmComponent
48
-    def __init__(self, data):
48
+    def __init__(self, data, components):
49 49
         if type(self) == EmComponent:
50 50
             raise NotImplementedError('Abstract class')
51 51
 
@@ -54,6 +54,7 @@ class EmComponent(object):
54 54
         # @warning \ref _fields instance property is not the same than EmComponent::_fields class property. In the instance property the EditorialModel::fieldtypes::EmFieldType are instanciated to be able to handle datas
55 55
         # @see EmComponent::_fields EditorialModel::fieldtypes::EmFieldType
56 56
         self._fields = OrderedDict([(name, ftype()) for (name, ftype) in (EmComponent._fields + self.__class__._fields)])
57
+        self.components = components
57 58
 
58 59
         for name, value in data.items():
59 60
             if name in self._fields:

+ 1
- 1
EditorialModel/model.py View File

@@ -37,7 +37,7 @@ class Model(object):
37 37
             if cls:
38 38
                 component['uid'] = uid
39 39
                 # create a dict for the component and one indexed by uids, store instanciated component in it
40
-                self.components[component['component']][uid] = self.components['uids'][uid] = cls(component)
40
+                self.components[component['component']][uid] = self.components['uids'][uid] = cls(component, self.components)
41 41
         # TODO : check integrity
42 42
 
43 43
     ## Saves data using the current backend

Loading…
Cancel
Save