fix label handling: when label is explicitly set to None, don't try to guess it
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jan 2010 20:22:13 +0100
changeset 4377 0e9cf6593382
parent 4376 839b28a3652e
child 4378 785c56bdacc6
fix label handling: when label is explicitly set to None, don't try to guess it
web/formfields.py
--- a/web/formfields.py	Tue Jan 26 16:48:41 2010 +0100
+++ b/web/formfields.py	Tue Jan 26 20:22:13 2010 +0100
@@ -112,7 +112,7 @@
     order = None
     value = _MARKER
 
-    def __init__(self, name=None, label=None, widget=None, **kwargs):
+    def __init__(self, name=None, label=_MARKER, widget=None, **kwargs):
         for key, val in kwargs.items():
             if key == 'initial':
                 warn('[3.6] use value instead of initial', DeprecationWarning,
@@ -121,7 +121,9 @@
             assert hasattr(self.__class__, key) and not key[0] == '_', key
             setattr(self, key, val)
         self.name = name
-        self.label = label or name
+        if label is _MARKER:
+            label = name or _MARKER
+        self.label = label
         # has to be done after other attributes initialization
         self.init_widget(widget)
         # ordering number for this field instance
@@ -148,7 +150,7 @@
         """automatically set .label when name is set"""
         assert name
         self.name = name
-        if not self.label:
+        if self.label is _MARKER:
             self.label = name
 
     def is_visible(self):