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
     # @param id_or_name int|str: name or id of the object
45
     # @param id_or_name int|str: name or id of the object
46
     # @throw TypeError if id_or_name is not an integer nor a string
46
     # @throw TypeError if id_or_name is not an integer nor a string
47
     # @throw NotImplementedError if called with EmComponent
47
     # @throw NotImplementedError if called with EmComponent
48
-    def __init__(self, data):
48
+    def __init__(self, data, components):
49
         if type(self) == EmComponent:
49
         if type(self) == EmComponent:
50
             raise NotImplementedError('Abstract class')
50
             raise NotImplementedError('Abstract class')
51
 
51
 
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
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
         # @see EmComponent::_fields EditorialModel::fieldtypes::EmFieldType
55
         # @see EmComponent::_fields EditorialModel::fieldtypes::EmFieldType
56
         self._fields = OrderedDict([(name, ftype()) for (name, ftype) in (EmComponent._fields + self.__class__._fields)])
56
         self._fields = OrderedDict([(name, ftype()) for (name, ftype) in (EmComponent._fields + self.__class__._fields)])
57
+        self.components = components
57
 
58
 
58
         for name, value in data.items():
59
         for name, value in data.items():
59
             if name in self._fields:
60
             if name in self._fields:

+ 1
- 1
EditorialModel/model.py View File

37
             if cls:
37
             if cls:
38
                 component['uid'] = uid
38
                 component['uid'] = uid
39
                 # create a dict for the component and one indexed by uids, store instanciated component in it
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
         # TODO : check integrity
41
         # TODO : check integrity
42
 
42
 
43
     ## Saves data using the current backend
43
     ## Saves data using the current backend

Loading…
Cancel
Save