|
@@ -14,12 +14,15 @@ class GenericFieldType(object):
|
14
|
14
|
## @brief List fields that will be exposed to the construct_data_method
|
15
|
15
|
_construct_datas_deps = []
|
16
|
16
|
|
17
|
|
- ## @param internal False | str : define wheter or not a field is internal
|
|
17
|
+ ## @brief Generic constructor for fieldtypes
|
|
18
|
+ # @param internal False | str : define wheter or not a field is internal
|
|
19
|
+ # @param immutable bool : indicate if the fieldtype has to be defined in child classes of LeObject or if it is defined globally and immutable
|
18
|
20
|
# @throw NotImplementedError if called from bad class
|
19
|
|
- def __init__(self, internal = False, **args):
|
|
21
|
+ def __init__(self, internal = False, immutable = False, **args):
|
20
|
22
|
if self.__class__ == GenericFieldType:
|
21
|
23
|
raise NotImplementedError("Abstract class")
|
22
|
24
|
self.internal = internal #Check this value ?
|
|
25
|
+ self.immutable = bool(immutable)
|
23
|
26
|
|
24
|
27
|
for argname, argval in args.items():
|
25
|
28
|
setattr(self, argname, argval)
|
|
@@ -234,4 +237,52 @@ class FieldTypeDataCheckError(FieldTypeError):
|
234
|
237
|
msg += "{expt_name}:{expt_msg}; ".format(expt_name=expt.__class__.__name__, expt_msg=str(expt))
|
235
|
238
|
return msg
|
236
|
239
|
|
237
|
|
-
|
|
240
|
+## @page lodel2_fieldtypes Lodel2 fieldtypes
|
|
241
|
+#
|
|
242
|
+# @section fieldtypes_features Main features
|
|
243
|
+#
|
|
244
|
+# Lodel2 defines Class and Types containing fields that handle values.
|
|
245
|
+# Fields are defined by FieldTypes. It's objects that are able to check datas value, to construct values (~cast) and to check datas consistency given the list of datas of an Lodel2 object (Class or Type)
|
|
246
|
+#
|
|
247
|
+# @subsection fieldtypes_hierarchy Fieldtypes family
|
|
248
|
+#
|
|
249
|
+# Fieldtypes are python objects. We use inheritance to defines FieldTypes. Here is a list of main FieldTypes inheritance :
|
|
250
|
+# - GenericFieldType
|
|
251
|
+# - SingleValueFieldType <- handles a single value
|
|
252
|
+# - ReferenceFieldType <- handles a reference to another field
|
|
253
|
+# - leo.EmFieldType <- handles references to a LeObject (designed for LeRelation)
|
|
254
|
+# - char.EmFieldType <- handles string
|
|
255
|
+# - integer.EmFieldType <- handles integer
|
|
256
|
+# - pk.EmFieldType <- handles primary keys (identifier)
|
|
257
|
+# - MultiValueFieldType <- handles multiple values identified by a key
|
|
258
|
+# - i18n.EmFieldType <- handles a string and its translations
|
|
259
|
+#
|
|
260
|
+# @subsection fieldtypes_options Fieldtypes main options
|
|
261
|
+#
|
|
262
|
+# There is 2 options that are common for every fieldtypes :
|
|
263
|
+# - internal : that indicate who construct the data. Possible values are
|
|
264
|
+# - False : the field is not internal, its user that provides datas
|
|
265
|
+# - 'automatic' : The field is internal, its leapi that provides datas (see construct in @ref fieldtypes_validator )
|
|
266
|
+# - 'autosql' : BAD NAME. The field is internal but it is the datasource that provide the data
|
|
267
|
+# - immutable : Its a boolean that indicate if a fieldtype defined in EditorialModel.classtypes is immutable or HAVE TO be defined in EmClass
|
|
268
|
+#
|
|
269
|
+# @subsubsection fieldtypes_options_single_value SingleValueFieldType options
|
|
270
|
+#
|
|
271
|
+# SingleValueFieldType have more standart options :
|
|
272
|
+# - nullable (boolean) : is None allowed as value
|
|
273
|
+# - uniq (boolean) : if True the value has to be uniq in all instances of concerned Lodel2 API object
|
|
274
|
+# - primary (boolean) : if True the field is an identifier (primary key)
|
|
275
|
+# - default : if given as argument defines a default value for the FieldType
|
|
276
|
+#
|
|
277
|
+# @subsection fieldtypes_validator Data validation
|
|
278
|
+#
|
|
279
|
+# For each Lodel2 API objects (LeObject, LeRelation, ...) there is a sequence that is run to check datas and transform them. Each step is run for each fieldtypes of a Lodel2 API object
|
|
280
|
+#
|
|
281
|
+# -# Check data : this is a basic data check (for example if an integer is expected and the string 'foo' is given the check will fails)
|
|
282
|
+# -# Construct data : this is a data 'casting' step, this method is called with all other datas from the Lodel2 API object as argument (to be able to construct datas with other parts of the object) @ref fieldtypes_construct_order
|
|
283
|
+# -# Datas consistency checks : this step, as the construct step, has all datas from the Lodel2 API object as argument, and check for the whole datas consistency
|
|
284
|
+#
|
|
285
|
+# @subsubsection fieldtypes_construct_order Data construction dependencies
|
|
286
|
+#
|
|
287
|
+# To handle data construction dependencies there is an object DatasConstructor able to call the data construction when needed and to detect (not tested yet) circular dependencies
|
|
288
|
+#
|