commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8519 - in trunk/gnue-forms/src: . GFObjects input/displayHandler


From: reinhard
Subject: [gnue] r8519 - in trunk/gnue-forms/src: . GFObjects input/displayHandlers
Date: Thu, 29 Jun 2006 04:47:33 -0500 (CDT)

Author: reinhard
Date: 2006-06-29 04:47:32 -0500 (Thu, 29 Jun 2006)
New Revision: 8519

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFObjects/GFEntry.py
   trunk/gnue-forms/src/GFObjects/GFField.py
   trunk/gnue-forms/src/GFObjects/GFTabStop.py
   trunk/gnue-forms/src/input/displayHandlers/Cursor.py
Log:
Fixed check for minimum field length.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-06-28 23:18:25 UTC (rev 8518)
+++ trunk/gnue-forms/src/GFForm.py      2006-06-29 09:47:32 UTC (rev 8519)
@@ -39,17 +39,6 @@
 from gnue.common.utils import CaselessDict
 
 # =============================================================================
-# Exceptions
-# =============================================================================
-
-class MinimumLengthError(errors.UserError):
-    def __init__ (self, min_length):
-        msg = u_("Minimum required length %d") % min_length
-        errors.UserError.__init__(self, msg)
-
-
-
-# =============================================================================
 # Implementation of the form tag
 # =============================================================================
 
@@ -750,9 +739,6 @@
         Changes focus to the requested entry object.
         @param widget: entry to put focus on
         @param fireFocusTriggers: whether to fire focus-change trigger?
-
-        @raises MinimumLengthError: if the field of an entry specifies a
-          minimum length and the current value is too short
         """
 
         # cannot change focus to same entry
@@ -764,16 +750,6 @@
 
         message = None
         try:
-            if self._currentEntry:
-                if self._currentEntry._type != 'GFButton':
-                    value = self._currentEntry.getValue()
-                    vstr  = "%s" % value
-
-                    minl = self._currentEntry._field.minLength
-                    if minl and value is not None and len (vstr):
-                        if len (vstr) < minl:
-                            raise MinimumLengthError (minl)
-
             fieldChange = widget != self._currentEntry
 
             # Determine wether the block should be changed.  Since buttons do

Modified: trunk/gnue-forms/src/GFObjects/GFEntry.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFEntry.py   2006-06-28 23:18:25 UTC (rev 
8518)
+++ trunk/gnue-forms/src/GFObjects/GFEntry.py   2006-06-29 09:47:32 UTC (rev 
8519)
@@ -127,13 +127,6 @@
 
         return self.navigable and self._block.navigable and not self.hidden
 
-    # -------------------------------------------------------------------------
-
-    def _validate_(self):
-
-        self._field.validate()
-
-
     # =========================================================================
     # Trigger functions
     # =========================================================================

Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py   2006-06-28 23:18:25 UTC (rev 
8518)
+++ trunk/gnue-forms/src/GFObjects/GFField.py   2006-06-29 09:47:32 UTC (rev 
8519)
@@ -46,14 +46,6 @@
         GParser.MarkupError.__init__ (self, msg, field._url, field._lineNumber)
 
 # =============================================================================
-
-class MinimumLengthError(errors.UserError):
-    def __init__(self, name, min_length):
-        msg = u_("Minimum required length for field '%(name)s': %(len)d") \
-                % {'name': name, 'len': min_length}
-        errors.UserError.__init__(self, msg)
-
-# =============================================================================
 # A field of a block
 # =============================================================================
 
@@ -279,26 +271,6 @@
 
 
     # -------------------------------------------------------------------------
-    # Validate
-    # -------------------------------------------------------------------------
-
-    def validate(self):
-        """
-        Validate the current value of the field
-
-        @raises MinimumLengthError: if a minimum field length is specified and
-          the current value is too short (but not None)
-        """
-        
-        value = self.getValue()
-        vstr  = "%s" % value
-
-        if self.minLength and value is not None:
-            if len(vstr) and len(vstr) < self.minLength:
-                raise MinimumLengthError(self.name, self.minLength)
-
-
-    # -------------------------------------------------------------------------
     # Implementation of virtual methods
     # -------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-06-28 23:18:25 UTC (rev 
8518)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-06-29 09:47:32 UTC (rev 
8519)
@@ -71,18 +71,6 @@
 
 
     # -------------------------------------------------------------------------
-    # Validate the object
-    # -------------------------------------------------------------------------
-
-    def validate(self):
-        """
-        Validates the object and/or its contents.
-        """
-
-        self._validate_()
-
-
-    # -------------------------------------------------------------------------
     # Implementation of virtual methods
     # -------------------------------------------------------------------------
 
@@ -116,13 +104,3 @@
                 return self.navigable and self._navigableInQuery_
             else:
                 return self.navigable and (not self.readonly)
-
-    # -------------------------------------------------------------------------
-
-    def _validate_(self):
-        """
-        Descendants can overwrite this method to perform a validation. If
-        validation fails, an exception must be raised.
-        """
-
-        pass

Modified: trunk/gnue-forms/src/input/displayHandlers/Cursor.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Cursor.py        2006-06-28 
23:18:25 UTC (rev 8518)
+++ trunk/gnue-forms/src/input/displayHandlers/Cursor.py        2006-06-29 
09:47:32 UTC (rev 8519)
@@ -49,8 +49,13 @@
           % {'value': value, 'field': field}
     errors.UserError.__init__ (self, msg)
 
+class MinimumLengthError(errors.UserError):
+  def __init__ (self, min_length):
+    msg = u_("Minimum required length %d") % min_length
+    errors.UserError.__init__(self, msg)
 
 
+
 # TODO: When Base is used inherit from that instead
 class BaseCursor(events.EventAware):
   """
@@ -225,19 +230,10 @@
     self._selection1 = None
 
     if self.modified:
-      # TODO: buildValue should raise an exception instead of return False
-      if self._buildValue():
-        if self.field._allowedValues and \
-           not self.field._allowedValues.has_key("%s" % self.value):
-            raise InvalidFieldValueError, (self.field.name, self.value)
+      self.__updateFieldValue()
+      self.editing = False
+      self._buildDisplay()
 
-        self.editing = False
-        self.field.setValue(self.value)
-
-        self._buildDisplay()
-
-      else:
-        raise InvalidFieldValueError, (self.field.name, self.work)
     else:
       self.editing = False
 
@@ -741,9 +737,23 @@
     """
 
     if self.isPending ():
-      if self._buildValue ():
-        if self.field._allowedValues and \
-           not self.field._allowedValues.has_key ("%s" % self.value):
+      try:
+        self.__updateFieldValue()
+      except:
+        pass
+
+  def __updateFieldValue(self):
+
+      # TODO: buildValue should raise an exception instead of return False
+      if not self._buildValue():
+        raise InvalidFieldValueError, (self.field.name, self.work)
+
+      if self.field._allowedValues and \
+         not self.field._allowedValues.has_key("%s" % self.value):
           raise InvalidFieldValueError, (self.field.name, self.value)
 
-        self.field.setValue (self.value)
+      if self.field.minLength and self.value is not None and len(self.value):
+          if len(self.value) < self.field.minLength:
+              raise MinimumLengthError(self.field.minLength)
+
+      self.field.setValue(self.value)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]