Browse Source

Adding of an attribute cast_type in UniqID datahandler, for a right insertion of uids in database

prieto 8 years ago
parent
commit
1cb07dc6bf
2 changed files with 4 additions and 3 deletions
  1. 2
    1
      lodel/leapi/datahandlers/datas.py
  2. 2
    2
      lodel/leapi/datahandlers/references.py

+ 2
- 1
lodel/leapi/datahandlers/datas.py View File

9
     help = 'Automatic string field, designed to use the str % operator to \
9
     help = 'Automatic string field, designed to use the str % operator to \
10
 build its content'
10
 build its content'
11
     base_type = 'char'
11
     base_type = 'char'
12
-
12
+    
13
     ##@brief Build its content with a field list and a format string
13
     ##@brief Build its content with a field list and a format string
14
     # @param format_string str
14
     # @param format_string str
15
     # @param max_length int : the maximum length of the handled value
15
     # @param max_length int : the maximum length of the handled value
65
 
65
 
66
     help = 'Fieldtype designed to handle editorial model UID'
66
     help = 'Fieldtype designed to handle editorial model UID'
67
     base_type = 'int'
67
     base_type = 'int'
68
+    cast_type = int
68
 
69
 
69
     ##@brief A uid field
70
     ##@brief A uid field
70
     # @param **kwargs
71
     # @param **kwargs

+ 2
- 2
lodel/leapi/datahandlers/references.py View File

42
 
42
 
43
         if isinstance(cur_value, str):
43
         if isinstance(cur_value, str):
44
             value = cur_value.split(',')
44
             value = cur_value.split(',')
45
-            l_value = [int(uid) for uid in value] ## à remplacer par uidtype
46
-            logger.debug(l_value)
45
+            l_value = [uidtype.cast_type(uid) for uid in value] ## à remplacer par uidtype
46
+
47
             return l_value
47
             return l_value
48
         elif isinstance(cur_value, list):
48
         elif isinstance(cur_value, list):
49
             type_list = str if isinstance(cur_value[0], str) else uidtype
49
             type_list = str if isinstance(cur_value[0], str) else uidtype

Loading…
Cancel
Save