|
@@ -5,9 +5,30 @@ class FieldDataHandler(object):
|
5
|
5
|
|
6
|
6
|
help_text = 'Generic Field Data Handler'
|
7
|
7
|
|
|
8
|
+ ## @brief List fields that will be exposed to the construct_data_method
|
|
9
|
+ _construct_datas_deps = []
|
|
10
|
+
|
8
|
11
|
## @brief constructor
|
9
|
|
- def __init__(self):
|
10
|
|
- pass
|
|
12
|
+ # @param internal False | str : define whether or not a field is internal
|
|
13
|
+ # @param immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is designed globally and immutable
|
|
14
|
+ # @param **args
|
|
15
|
+ def __init__(self, internal=False, immutable=False, **args):
|
|
16
|
+ self.internal = internal # Check this value ?
|
|
17
|
+ self.immutable = bool(immutable)
|
|
18
|
+
|
|
19
|
+ for argname, argval in args.items():
|
|
20
|
+ setattr(self, argname, argval)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ ## Fieldtype name
|
|
24
|
+ @staticmethod
|
|
25
|
+ def name(cls):
|
|
26
|
+ return cls.__module__.split('.')[-1]
|
|
27
|
+
|
|
28
|
+ ## @brief checks if a fieldtype is internal
|
|
29
|
+ # @return bool
|
|
30
|
+ def is_internal(self):
|
|
31
|
+ return self.internal != False
|
11
|
32
|
|
12
|
33
|
## @brief calls the data_field defined _check_data_value() method
|
13
|
34
|
# @return tuple (value, error|None)
|
|
@@ -31,3 +52,10 @@ class FieldDataHandler(object):
|
31
|
52
|
@staticmethod
|
32
|
53
|
def module_name(self, fieldtype_name):
|
33
|
54
|
return 'leapi.datahandlers.data_fields.%s' % fieldtype_name
|
|
55
|
+
|
|
56
|
+ ## @brief __hash__ implementation for fieldtypes
|
|
57
|
+ def __hash__(self):
|
|
58
|
+ hash_dats = [self.__class__.__module__]
|
|
59
|
+ for kdic in sorted([k for k in self.__dict__.keys() if not k.startswith('_')]):
|
|
60
|
+ hash_dats.append((kdic, getattr(self, kdic)))
|
|
61
|
+ return hash(tuple(hash_dats))
|