|
@@ -138,6 +138,15 @@ class EmClass(EmComponent):
|
138
|
138
|
return list(fields.values()) if uid is None else fields[uid]
|
139
|
139
|
except KeyError:
|
140
|
140
|
raise EditorialModelError("No such EmField '%s'" % uid)
|
|
141
|
+
|
|
142
|
+ ##@brief Keep in __fields only fields contained in active groups
|
|
143
|
+ 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 }
|
141
|
150
|
|
142
|
151
|
##@brief Add a field to the EmClass
|
143
|
152
|
# @param emfield EmField : an EmField instance
|
|
@@ -145,6 +154,7 @@ class EmClass(EmComponent):
|
145
|
154
|
# @throw EditorialModelException if an EmField with same uid allready in this EmClass (overwritting allowed from parents)
|
146
|
155
|
# @todo End the override checks (needs methods in data_handlers)
|
147
|
156
|
def add_field(self, emfield):
|
|
157
|
+ assert_edit()
|
148
|
158
|
if emfield.uid in self.__fields:
|
149
|
159
|
raise EditorialModelError("Duplicated uid '%s' for EmField in this class ( %s )" % (emfield.uid, self))
|
150
|
160
|
# Incomplete field override check
|
|
@@ -161,6 +171,7 @@ class EmClass(EmComponent):
|
161
|
171
|
# @param uid str : the EmField uniq id
|
162
|
172
|
# @param **field_kwargs : EmField constructor parameters ( see @ref EmField.__init__() )
|
163
|
173
|
def new_field(self, uid, data_handler, **field_kwargs):
|
|
174
|
+ assert_edit()
|
164
|
175
|
return self.add_field(EmField(uid, data_handler, **field_kwargs))
|
165
|
176
|
|
166
|
177
|
def d_hash(self):
|
|
@@ -317,6 +328,7 @@ class EmGroup(object):
|
317
|
328
|
##@brief Add components in a group
|
318
|
329
|
# @param components list : EmComponent instances list
|
319
|
330
|
def add_components(self, components):
|
|
331
|
+ assert_edit()
|
320
|
332
|
for component in components:
|
321
|
333
|
if isinstance(component, EmField):
|
322
|
334
|
if component._emclass is None:
|
|
@@ -328,6 +340,7 @@ class EmGroup(object):
|
328
|
340
|
##@brief Add a dependencie
|
329
|
341
|
# @param em_group EmGroup|iterable : an EmGroup instance or list of instance
|
330
|
342
|
def add_dependencie(self, grp):
|
|
343
|
+ assert_edit()
|
331
|
344
|
try:
|
332
|
345
|
for group in grp:
|
333
|
346
|
self.add_dependencie(group)
|
|
@@ -345,6 +358,7 @@ class EmGroup(object):
|
345
|
358
|
# @param em_group EmGroup|iterable : an EmGroup instance or list of instance
|
346
|
359
|
# Useless ???
|
347
|
360
|
def add_applicant(self, grp):
|
|
361
|
+ assert_edit()
|
348
|
362
|
try:
|
349
|
363
|
for group in grp:
|
350
|
364
|
self.add_applicant(group)
|