[rhmessaging-commits] rhmessaging commits: r4231 - mgmt/newdata/wooly/python/wooly.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Aug 26 16:29:11 EDT 2010


Author: justi9
Date: 2010-08-26 16:29:10 -0400 (Thu, 26 Aug 2010)
New Revision: 4231

Modified:
   mgmt/newdata/wooly/python/wooly/forms.py
   mgmt/newdata/wooly/python/wooly/forms.strings
Log:
Fixes some form validation errors that Jasan ran into; correct some error text

Modified: mgmt/newdata/wooly/python/wooly/forms.py
===================================================================
--- mgmt/newdata/wooly/python/wooly/forms.py	2010-08-26 19:56:41 UTC (rev 4230)
+++ mgmt/newdata/wooly/python/wooly/forms.py	2010-08-26 20:29:10 UTC (rev 4231)
@@ -412,12 +412,22 @@
         return self.input.set(session, value)
 
     def validate(self, session):
-        value = self.get(session)
+        super(ScalarField, self).validate(session)
 
-        if value in ("", None) and self.required:
-            error = MissingValueError(self)
-            self.form.errors.add(session, error)
+        if self.required:
+            value = self.get(session)
 
+            if value is None:
+                error = MissingValueError(self)
+                self.form.errors.add(session, error)
+
+            if isinstance(value, str):
+                value = value.strip()
+
+                if value == "":
+                    error = MissingValueError(self)
+                    self.form.errors.add(session, error)
+
     def render_inputs(self, session, *args):
         return self.input.render(session)
 
@@ -450,6 +460,8 @@
         self.add_child(self.input)
 
     def validate(self, session):
+        super(IntegerField, self).validate(session)
+
         value = self.get(session)
 
         if value:
@@ -457,8 +469,8 @@
                 value = int(value)
             except:
                 title = self.render_title(session)
-                message = "The '%s' field must be a number" % title
-                self.form.errors.append(FormError(message))
+                message = "The '%s' field must be an integer" % title
+                self.form.errors.add(session, FormError(message))
 
 # XXX make this use a RadioInputSet instead?
 class RadioField(FormField):

Modified: mgmt/newdata/wooly/python/wooly/forms.strings
===================================================================
--- mgmt/newdata/wooly/python/wooly/forms.strings	2010-08-26 19:56:41 UTC (rev 4230)
+++ mgmt/newdata/wooly/python/wooly/forms.strings	2010-08-26 20:29:10 UTC (rev 4231)
@@ -30,7 +30,7 @@
 <div class="FormErrorSet">
   <p>
     <img src="resource?name=warning-36.png"/>
-    Input errors
+    Errors
   </p>
 
   <ul>{items}</ul>



More information about the rhmessaging-commits mailing list