[Checkins] SVN: z3c.currency/trunk/src/z3c/currency/ fixed wrong call to validate

Roy Mathew roymath at yahoo.com
Wed Jul 25 18:55:36 EDT 2007


Log message for revision 78339:
  fixed wrong call to validate

Changed:
  U   z3c.currency/trunk/src/z3c/currency/README.txt
  U   z3c.currency/trunk/src/z3c/currency/field.py

-=-
Modified: z3c.currency/trunk/src/z3c/currency/README.txt
===================================================================
--- z3c.currency/trunk/src/z3c/currency/README.txt	2007-07-25 22:46:45 UTC (rev 78338)
+++ z3c.currency/trunk/src/z3c/currency/README.txt	2007-07-25 22:55:36 UTC (rev 78339)
@@ -99,6 +99,14 @@
   ...
   ValidationError: The value must have two decimal places.
 
+If the field is not required, ...
+
+  >>> price.required = False
+
+let's make sure that the validation still passes.
+
+  >>> price.validate(None)
+
 Note that the ``IFromUnicode`` interface is purposefully not supported:
 
   >>> price.fromUnicode

Modified: z3c.currency/trunk/src/z3c/currency/field.py
===================================================================
--- z3c.currency/trunk/src/z3c/currency/field.py	2007-07-25 22:46:45 UTC (rev 78338)
+++ z3c.currency/trunk/src/z3c/currency/field.py	2007-07-25 22:55:36 UTC (rev 78339)
@@ -34,7 +34,7 @@
         self.precision = precision
         self.unit = unit
 
-    def validate(self, value):
+    def _validate(self, value):
         if not isinstance(value, decimal.Decimal):
             raise zope.schema.ValidationError(
                 "Value must be of type 'Decimal', not '%s'." % (
@@ -48,4 +48,4 @@
             raise zope.schema.ValidationError(
                 "The value must have two decimal places.")
 
-        super(Currency, self).validate(value)
+        super(Currency, self)._validate(value)



More information about the Checkins mailing list