[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/Views/Browser - Widget.py:1.14.2.1

Jim Fulton jim@zope.com
Thu, 12 Dec 2002 10:16:50 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv21998/Views/Browser

Modified Files:
      Tag: AdapterAndView-branch
	Widget.py 
Log Message:
Changed the widget haveData method to run the conversion api to make
sure that there is non-missing data, not just form data.


=== Zope3/lib/python/Zope/App/Forms/Views/Browser/Widget.py 1.14 => 1.14.2.1 ===
--- Zope3/lib/python/Zope/App/Forms/Views/Browser/Widget.py:1.14	Wed Dec 11 08:52:48 2002
+++ Zope3/lib/python/Zope/App/Forms/Views/Browser/Widget.py	Thu Dec 12 10:16:50 2002
@@ -44,7 +44,9 @@
     _missing = None
 
     def haveData(self):
-        return (self.name) in self.request.form
+        if (self.name) in self.request.form:
+            return self._convert(self.request[self.name]) is not None
+        return False
 
     def getData(self, optional=0):
         field = self.context
@@ -196,6 +198,11 @@
     style = "width:100%"
     __values = None
 
+    def _convert(self, value):
+        if self.context.min_length and not value:
+            return None
+        return value
+
     def __init__(self, *args):
         super(TextWidget, self).__init__(*args)
         
@@ -264,6 +271,9 @@
 class Bytes:
 
     def _convert(self, value):
+        if self.context.min_length and not value:
+            return None
+
         value = super(Bytes, self)._convert(value)
         if type(value) is unicode:
             value = value.encode('ascii')
@@ -293,6 +303,11 @@
     height = 15
     extra=""
     style="width:100%"
+
+    def _convert(self, value):
+        if self.context.min_length and not value:
+            return None
+        return value
     
     def __call__(self):
         'See Zope.App.Forms.Views.Browser.IBrowserWidget.IBrowserWidget'