Commits

James Crasta  committed d4f664e

Integer/Float/DecimalField all set .data to None on coercion error for consistency

  • Participants
  • Parent commits c22360b

Comments (0)

Files changed (3)

   * Support PGInet, MACADDR, and UUID field conversion
   * Support callable defaults
 
+- ext.appengine:
+  * model_form now supports generating forms with the same ordering as model.
+  * ReferencePropertyField now gets get_label like the other ORM fields
+
 - Add localization support for WTForms built-in messages
 
+- Minor changes/fixes:
+  * An empty label string can be specified on fields if desired
+  * Option widget can now take kwargs customization
+  * Field subclasses can provide default validators as a class property
+  * DateTimeField can take time in microseconds
+  * Numeric fields all set .data to None on coercion error for consistency.
+
 
 Version 0.6.3
 -------------

File tests/fields.py

         form = self.F(DummyPostData(a=[], b=['']))
         self.assertEqual(form.a.data, None)
         self.assertEqual(form.a.raw_data, [])
-        self.assertEqual(form.b.data, 48)
+        self.assertEqual(form.b.data, None)
         self.assertEqual(form.b.raw_data, [''])
         self.assert_(not form.validate())
         self.assertEqual(len(form.b.process_errors), 1)
         self.assertEqual(form.a._value(), u'2.10')
         self.assert_(form.validate())
         form = F(DummyPostData(a='2,1'), a=Decimal(5))
-        self.assertEqual(form.a.data, Decimal(5))
+        self.assertEqual(form.a.data, None)
         self.assertEqual(form.a.raw_data, ['2,1'])
         self.assert_(not form.validate())
 
         self.assert_(form.b.validate(form))
         form = self.F(DummyPostData(a=[], b=['']))
         self.assertEqual(form.a.data, None)
-        self.assertEqual(form.b.data, 48.0)
+        self.assertEqual(form.b.data, None)
         self.assertEqual(form.b.raw_data, [u''])
         self.assert_(not form.validate())
         self.assertEqual(len(form.b.process_errors), 1)

File wtforms/fields/core.py

             try:
                 self.data = int(valuelist[0])
             except ValueError:
+                self.data = None
                 raise ValueError(self.gettext(u'Not a valid integer value'))
 
 
             try:
                 self.data = decimal.Decimal(valuelist[0])
             except (decimal.InvalidOperation, ValueError):
+                self.data = None
                 raise ValueError(self.gettext(u'Not a valid decimal value'))
 
 
             try:
                 self.data = float(valuelist[0])
             except ValueError:
+                self.data = None
                 raise ValueError(self.gettext(u'Not a valid float value'))