|
@@ -7,6 +7,7 @@ import hashlib
|
7
|
7
|
|
8
|
8
|
from lodel.utils.mlstring import MlString
|
9
|
9
|
|
|
10
|
+from lodel.settings import Settings
|
10
|
11
|
from lodel.editorial_model.exceptions import *
|
11
|
12
|
from lodel.leapi.leobject import CLASS_ID_FIELDNAME
|
12
|
13
|
|
|
@@ -84,6 +85,12 @@ class EmClass(EmComponent):
|
84
|
85
|
##@brief Stores EmFields instances indexed by field uid
|
85
|
86
|
self.__fields = dict()
|
86
|
87
|
|
|
88
|
+ self.group = group
|
|
89
|
+ if group is None:
|
|
90
|
+ warnings.warn("NO GROUP FOR EMCLASS %s" % uid)
|
|
91
|
+ else:
|
|
92
|
+ group.add_components([self])
|
|
93
|
+
|
87
|
94
|
#Adding common field
|
88
|
95
|
if not self.abstract:
|
89
|
96
|
self.new_field(
|
|
@@ -95,10 +102,9 @@ class EmClass(EmComponent):
|
95
|
102
|
'eng': "Allow to create instance of the good class when\
|
96
|
103
|
fetching arbitrary datas from DB"},
|
97
|
104
|
data_handler = 'LeobjectSubclassIdentifier',
|
98
|
|
- internal = True)
|
99
|
|
- if group is not None:
|
100
|
|
- group.add_components([self])
|
101
|
|
-
|
|
105
|
+ internal = True,
|
|
106
|
+ group = group)
|
|
107
|
+
|
102
|
108
|
##@brief Property that represent a dict of all fields (the EmField defined in this class and all its parents)
|
103
|
109
|
# @todo use Settings.editorialmodel.groups to determine wich fields should be returned
|
104
|
110
|
@property
|
|
@@ -141,12 +147,13 @@ class EmClass(EmComponent):
|
141
|
147
|
|
142
|
148
|
##@brief Keep in __fields only fields contained in active groups
|
143
|
149
|
def _set_active_fields(self, active_groups):
|
144
|
|
- active_fields = []
|
145
|
|
- for grp_name, agrp in active_groups.items():
|
146
|
|
- active_fields += [ emc for emc in agrp.components()
|
147
|
|
- if isinstance(emc, EmField)]
|
148
|
|
- self.__fields = { fname:fdh for fname, fdh in self.__fields.items()
|
149
|
|
- if fdh in active_fields }
|
|
150
|
+ if not Settings.editorialmodel.editormode:
|
|
151
|
+ active_fields = []
|
|
152
|
+ for grp_name, agrp in active_groups.items():
|
|
153
|
+ active_fields += [ emc for emc in agrp.components()
|
|
154
|
+ if isinstance(emc, EmField)]
|
|
155
|
+ self.__fields = { fname:fdh for fname, fdh in self.__fields.items()
|
|
156
|
+ if fdh in active_fields }
|
150
|
157
|
|
151
|
158
|
##@brief Add a field to the EmClass
|
152
|
159
|
# @param emfield EmField : an EmField instance
|
|
@@ -222,6 +229,10 @@ class EmField(EmComponent):
|
222
|
229
|
self.data_handler_options = handler_kwargs
|
223
|
230
|
##@brief Stores the emclass that contains this field (set by EmClass.add_field() method)
|
224
|
231
|
self._emclass = None
|
|
232
|
+ if group is None:
|
|
233
|
+ warnings.warn("NO GROUP FOR FIELD %s" % uid)
|
|
234
|
+ else:
|
|
235
|
+ group.add_components([self])
|
225
|
236
|
|
226
|
237
|
##@brief Returns data_handler_name attribute
|
227
|
238
|
def get_data_handler_name(self):
|