[Zope3-checkins] SVN: Zope3/trunk/ Fix issue 448, SingleDataHelper.hidden() raised a LookupError if there was no

Bjorn Tillenius bjorn.tillenius at gmail.com
Wed Apr 12 06:16:53 EDT 2006


Log message for revision 66879:
  Fix issue 448, SingleDataHelper.hidden() raised a LookupError if there was no
  input.
  
  This is only a workaround for http://www.zope.org/Collectors/Zope3-dev/584,
  though, which is much harder to fix.
  
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/form/browser/itemswidgets.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-04-12 10:04:50 UTC (rev 66878)
+++ Zope3/trunk/doc/CHANGES.txt	2006-04-12 10:16:53 UTC (rev 66879)
@@ -125,12 +125,15 @@
 
       - Fixed a NameError in bin/static-apidoc.
 
+      - Fixed issue 448, SingleDataHelper.hidden() raised a LookupError
+        if there was no input value.
+
     Much thanks to everyone who contributed to this release:
 
       Jim Fulton, Marius Gedminas, Brian Sutherland, Stephan Richter, Dmitry
       Vasiliev, Tim Peters, Zachery Bir, Gary Poster, Egon Frerich, Zhiyun
       (Simon) Hang, Tadashi Matsumoto, Simon Michael, Encople Degoute,
-      Shane Hathaway
+      Shane Hathaway, Bjorn Tillenius
 
   ------------------------------------------------------------------
 

Modified: Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/itemswidgets.py	2006-04-12 10:04:50 UTC (rev 66878)
+++ Zope3/trunk/src/zope/app/form/browser/itemswidgets.py	2006-04-12 10:16:53 UTC (rev 66879)
@@ -161,12 +161,21 @@
             return self.context.missing_value
 
     def hidden(self):
+        #XXX: _getFormValue() should return a string value that can be
+        #     used in a HTML form, but it doesn't. When
+        #     http://www.zope.org/Collectors/Zope3-dev/584 gets fixed
+        #     this hack should be reverted.
+        #     -- Bjorn Tillenius, 2006-04-12
+        value = self._getFormValue()
+        if value == self._missing:
+            form_value = ''
+        else:
+            form_value = self.vocabulary.getTerm(value).token
         return renderElement(u'input',
                              type='hidden',
                              name=self.name,
                              id=self.name,
-                             value=self.vocabulary.getTerm(
-                                self._getFormValue()).token,
+                             value=form_value,
                              cssClass=self.cssClass,
                              extra=self.extra)
 



More information about the Zope3-Checkins mailing list