Browse Source

The check_data_value method of the Varchar Datahandler is now using the max_length parameter

Roland Haroutiounian 8 years ago
parent
commit
925d42fb8e
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      lodel/leapi/datahandlers/datas_base.py

+ 5
- 1
lodel/leapi/datahandlers/datas_base.py View File

72
         error = None
72
         error = None
73
         try:
73
         try:
74
             value = str(value)
74
             value = str(value)
75
-        except(ValueError, TypeError):
75
+            if len(value) > self.max_length:
76
+                raise ValueError
77
+        except TypeError:
76
             error = TypeError("The value '%s' can't be a str" % value)
78
             error = TypeError("The value '%s' can't be a str" % value)
79
+        except ValueError:
80
+            error = ValueError("The value '%s' is longer than the maximum length of this field (%s)" % (value, self.max_length))
77
         return value, error
81
         return value, error
78
 
82
 
79
 ##@brief Data field designed to handle date & time 
83
 ##@brief Data field designed to handle date & time 

Loading…
Cancel
Save