[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - vocabularywidget.py:1.63.4.1 widget.py:1.64.4.4

Garrett Smith garrett at mojave-corp.com
Sat Feb 7 23:36:41 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv29659/src/zope/app/browser/form

Modified Files:
      Tag: ozzope-widgets-branch
	vocabularywidget.py widget.py 
Log Message:

- Removed the use of getValue for widget attributes - using the attributes
  directly.

- Changed type attribute of widgets to inputType - this will be clarified
  further in the widget interfaces.

- Fixed some trivial whitespace issues.


=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.63 => 1.63.4.1 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.63	Thu Feb  5 09:55:46 2004
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py	Sat Feb  7 23:36:00 2004
@@ -165,7 +165,7 @@
 class VocabularyWidgetBase(ViewSupport, widget.BrowserWidget):
     """Convenience base class for vocabulary-based widgets."""
 
-    propertyNames = widget.BrowserWidget.propertyNames + ["extra"]
+    propertyNames = ["extra"]
 
     extra = ""
     type = "vocabulary"
@@ -324,8 +324,7 @@
 
 class VocabularyMultiDisplayWidget(MultiDataHelper, VocabularyWidgetBase):
 
-    propertyNames = (VocabularyWidgetBase.propertyNames
-                     + ['itemTag', 'tag'])
+    propertyNames = ['itemTag', 'tag']
 
     itemTag = 'li'
     tag = 'ol'
@@ -333,23 +332,23 @@
     def render(self, value):
         if value:
             rendered_items = self.renderItems(value)
-            return widget.renderElement(self.getValue('tag'),
-                                        type=self.getValue('type'),
+            return widget.renderElement(self.tag,
+                                        type=self.inputType,
                                         name=self.name,
                                         id=self.name,
-                                        cssClass=self.getValue('cssClass'),
+                                        cssClass=self.cssClass,
                                         contents="\n".join(rendered_items),
-                                        extra=self.getValue('extra'))
+                                        extra=self.extra)
         else:
             return self.translate(_msg_missing_multiple_value_display)
 
     def renderItems(self, value):
         L = []
         vocabulary = self.context.vocabulary
-        cssClass = self.getValue('cssClass') or ''
+        cssClass = self.cssClass or ''
         if cssClass:
             cssClass += "-item"
-        tag = self.getValue('itemTag')
+        tag = self.itemTag
         for v in value:
             term = vocabulary.getTerm(v)
             L.append(widget.renderElement(tag,
@@ -403,8 +402,7 @@
 
 
 class VocabularyEditWidgetBase(VocabularyWidgetBase):
-    propertyNames = (VocabularyWidgetBase.propertyNames
-                     + ['size', 'tag'])
+    propertyNames = ['size', 'tag']
     size = 5
     tag = 'select'
 
@@ -446,7 +444,7 @@
             s = self.queryview.renderInput()
             if s:
                 contents.append(self._div('queryinput', s))
-        return self._div(self.getValue('cssClass'), "\n".join(contents),
+        return self._div(self.cssClass, "\n".join(contents),
                          id=self.name)
 
     def _div(self, cssClass, contents, **kw):
@@ -461,7 +459,7 @@
         """Render the list of possible values, with those found in
         'values' being marked as selected."""
 
-        cssClass = self.getValue('cssClass')
+        cssClass = self.cssClass
 
         # multiple items with the same value are not allowed from a
         # vocabulary, so that need not be considered here
@@ -508,7 +506,7 @@
     to be small.
     """
     implements(implementedBy(widget.SingleItemsWidget))
-    propertyNames = VocabularyEditWidgetBase.propertyNames + ['firstItem']
+    propertyNames = ['firstItem']
     firstItem = False
 
     _msg_no_value = _msg_missing_single_value_edit
@@ -559,7 +557,7 @@
             values = ()
         L = self.renderItemsWithValues(values)
         if not self.context.required:
-            cssClass = self.getValue('cssClass')
+            cssClass = self.cssClass
             kwargs = {
                 'value':'',
                 'name':self.name,
@@ -580,7 +578,7 @@
     to be very large.
     """
     implements(implementedBy(widget.SingleItemsWidget))
-    propertyNames = VocabularyEditWidgetBase.propertyNames + ['firstItem']
+    propertyNames = ['firstItem']
     firstItem = False
 
     _msg_no_value = _msg_missing_single_value_edit
@@ -591,8 +589,8 @@
         return widget.renderElement('select',
                                     name=self.name,
                                     contents=contents,
-                                    size=self.getValue('size'),
-                                    extra=self.getValue('extra'))
+                                    size=self.size,
+                                    extra=self.extra)
 
     def renderItems(self, value):
         vocabulary = self.context.vocabulary
@@ -637,12 +635,12 @@
         # All we really add here is the ':list' in the name argument
         # to widget.renderElement().
         rendered_items = self.renderItems(value)
-        return widget.renderElement(self.getValue('tag'),
+        return widget.renderElement(self.tag,
                                     name=self.name + ':list',
                                     multiple=None,
-                                    size=self.getValue('size'),
+                                    size=self.size,
                                     contents="\n".join(rendered_items),
-                                    extra=self.getValue('extra'))
+                                    extra=self.extra)
 
 
 class VocabularyQueryViewBase(ActionHelper, ViewSupport, BrowserView):


=== Zope3/src/zope/app/browser/form/widget.py 1.64.4.3 => 1.64.4.4 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.64.4.3	Sat Feb  7 21:52:25 2004
+++ Zope3/src/zope/app/browser/form/widget.py	Sat Feb  7 23:36:00 2004
@@ -146,7 +146,7 @@
     implements(IBrowserWidget)
 
     tag = 'input'
-    type = 'text'
+    inputType = 'text'
     cssClass = ''
     extra = ''
     _missing = ''
@@ -263,22 +263,22 @@
         return self.context.default
 
     def __call__(self):
-        return renderElement(self.getValue('tag'),
-                             type = self.getValue('type'),
-                             name = self.name,
-                             id = self.name,
-                             value = self._showData(),
-                             cssClass = self.getValue('cssClass'),
-                             extra = self.getValue('extra'))
+        return renderElement(self.tag,
+                             type=self.inputType,
+                             name=self.name,
+                             id=self.name,
+                             value=self._showData(),
+                             cssClass=self.cssClass,
+                             extra=self.extra)
 
     def hidden(self):
-        return renderElement(self.getValue('tag'),
-                             type = 'hidden',
-                             name = self.name,
-                             id = self.name,
-                             value = self._showData(),
-                             cssClass = self.getValue('cssClass'),
-                             extra = self.getValue('extra'))
+        return renderElement(self.tag,
+                             type='hidden',
+                             name=self.name,
+                             id=self.name,
+                             value=self._showData(),
+                             cssClass=self.cssClass,
+                             extra=self.extra)
 
     def render(self, value):
         warn("The widget render method is deprecated",
@@ -401,7 +401,7 @@
     
     implements(interfaces.ICheckBoxWidget)
     
-    type = 'checkbox'
+    inputType = 'checkbox'
     default = 0
     extra = ''
 
@@ -412,18 +412,18 @@
         else:
             kw = {}
         return "%s %s" % (
-            renderElement(self.getValue('tag'),
-                          type = 'hidden',
-                          name = self.name+".used",
-                          id = self.name+".used",
+            renderElement(self.tag,
+                          type='hidden',
+                          name=self.name+".used",
+                          id=self.name+".used",
                           value=""
                           ),
-            renderElement(self.getValue('tag'),
-                             type = self.getValue('type'),
-                             name = self.name,
-                             id = self.name,
-                             cssClass = self.getValue('cssClass'),
-                             extra = self.getValue('extra'),
+            renderElement(self.tag,
+                             type=self.inputType,
+                             name=self.name,
+                             id=self.name,
+                             cssClass=self.cssClass,
+                             extra=self.extra,
                              **kw),
             )
 
@@ -496,9 +496,7 @@
       />
 
     """
-    propertyNames = (BrowserWidget.propertyNames +
-                     ['displayWidth', 'displayMaxWidth', 'extra', 'default']
-                     )
+    propertyNames = ['displayWidth', 'displayMaxWidth', 'extra', 'default']
     default = ''
     displayWidth = 20
     displayMaxWidth = ""
@@ -512,28 +510,28 @@
         super(TextWidget, self).__init__(*args)
 
     def __call__(self):
-        displayMaxWidth = self.getValue('displayMaxWidth') or 0
+        displayMaxWidth = self.displayMaxWidth or 0
         if displayMaxWidth > 0:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 value = self._showData(),
-                                 cssClass = self.getValue('cssClass'),
-                                 style = self.style,
-                                 size = self.getValue('displayWidth'),
-                                 maxlength = displayMaxWidth,
-                                 extra = self.getValue('extra'))
-        else:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 value = self._showData(),
-                                 cssClass = self.getValue('cssClass'),
-                                 style = self.style,
-                                 size = self.getValue('displayWidth'),
-                                 extra = self.getValue('extra'))
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 value=self._showData(),
+                                 cssClass=self.cssClass,
+                                 style=self.style,
+                                 size=self.displayWidth,
+                                 maxlength=displayMaxWidth,
+                                 extra=self.extra)
+        else:
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 value=self._showData(),
+                                 cssClass=self.cssClass,
+                                 style=self.style,
+                                 size=self.displayWidth,
+                                 extra=self.extra)
 
 class Bytes(BrowserWidget):
 
@@ -674,7 +672,7 @@
     dude!</textarea>
 
     """
-    propertyNames = BrowserWidget.propertyNames + ['width', 'height', 'extra']
+    propertyNames = ['width', 'height', 'extra']
 
     default = ""
     width = 60
@@ -696,14 +694,14 @@
 
     def __call__(self):
         return renderElement("textarea",
-                             name = self.name,
-                             id = self.name,
-                             cssClass = self.getValue('cssClass'),
-                             rows = self.getValue('height'),
-                             cols = self.getValue('width'),
-                             style = self.style,
-                             contents = self._showData(),
-                             extra = self.getValue('extra'))
+                             name=self.name,
+                             id=self.name,
+                             cssClass=self.cssClass,
+                             rows=self.height,
+                             cols=self.width,
+                             style=self.style,
+                             contents=self._showData(),
+                             extra=self.extra)
 
 class BytesAreaWidget(Bytes, TextAreaWidget):
     """BytesArea widget.
@@ -724,31 +722,32 @@
 
 class PasswordWidget(TextWidget):
     """Password Widget"""
-    type='password'
+    
+    inputType = 'password'
 
     def __call__(self):
-        displayMaxWidth = self.getValue('displayMaxWidth') or 0
+        displayMaxWidth = self.displayMaxWidth or 0
         if displayMaxWidth > 0:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 value = '',
-                                 cssClass = self.getValue('cssClass'),
-                                 style = self.style,
-                                 size = self.getValue('displayWidth'),
-                                 maxlength = displayMaxWidth,
-                                 extra = self.getValue('extra'))
-        else:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 value = '',
-                                 cssClass = self.getValue('cssClass'),
-                                 style = self.style,
-                                 size = self.getValue('displayWidth'),
-                                 extra = self.getValue('extra'))
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 value='',
+                                 cssClass=self.cssClass,
+                                 style=self.style,
+                                 size=self.displayWidth,
+                                 maxlength=displayMaxWidth,
+                                 extra=self.extra)
+        else:
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 value='',
+                                 cssClass=self.cssClass,
+                                 style=self.style,
+                                 size=self.displayWidth,
+                                 extra=self.extra)
 
     def hidden(self):
         raise NotImplementedError(
@@ -756,27 +755,28 @@
 
 class FileWidget(TextWidget):
     """File Widget"""
-    type = 'file'
+    
+    inputType = 'file'
 
     def __call__(self):
-        displayMaxWidth = self.getValue('displayMaxWidth') or 0
+        displayMaxWidth = self.displayMaxWidth or 0
         if displayMaxWidth > 0:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 cssClass = self.getValue('cssClass'),
-                                 size = self.getValue('displayWidth'),
-                                 maxlength = displayMaxWidth,
-                                 extra = self.getValue('extra'))
-        else:
-            return renderElement(self.getValue('tag'),
-                                 type = self.getValue('type'),
-                                 name = self.name,
-                                 id = self.name,
-                                 cssClass = self.getValue('cssClass'),
-                                 size = self.getValue('displayWidth'),
-                                 extra = self.getValue('extra'))
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 cssClass=self.cssClass,
+                                 size=self.displayWidth,
+                                 maxlength=displayMaxWidth,
+                                 extra=self.extra)
+        else:
+            return renderElement(self.tag,
+                                 type=self.inputType,
+                                 name=self.name,
+                                 id=self.name,
+                                 cssClass=self.cssClass,
+                                 size=self.displayWidth,
+                                 extra=self.extra)
 
     def hasInput(self):
         file = self.request.form.get(self.name)
@@ -847,7 +847,7 @@
             and len(items) > 0):
             value = items[0]
 
-        cssClass = self.getValue('cssClass')
+        cssClass = self.cssClass
 
         # FIXME: what if we run into multiple items with same value?
         rendered_items = []
@@ -876,20 +876,18 @@
 
 class ListWidget(SingleItemsWidget):
     """List widget."""
-    propertyNames = (SingleItemsWidget.propertyNames +
-                     ['firstItem', 'items', 'size', 'extra']
-                     )
+    propertyNames = ['firstItem', 'items', 'size', 'extra']
     size = 5
 
     def __call__(self):
         renderedItems = self.renderItems(self._showData())
         return renderElement('select',
-                              name = self.name,
-                              id = self.name,
-                              cssClass = self.getValue('cssClass'),
-                              size = self.getValue('size'),
-                              contents = "\n".join(renderedItems),
-                              extra = self.getValue('extra'))
+                              name=self.name,
+                              id=self.name,
+                              cssClass=self.cssClass,
+                              size=self.size,
+                              contents="\n".join(renderedItems),
+                              extra=self.extra)
 
     def renderItem(self, index, text, value, name, cssClass):
         return renderElement('option', contents=text, value=value,
@@ -902,13 +900,12 @@
 
 class RadioWidget(SingleItemsWidget):
     """Radio buttons widget."""
-    propertyNames = SingleItemsWidget.propertyNames + \
-                     ['firstItem', 'orientation']
+    propertyNames = ['firstItem', 'orientation']
     orientation = "vertical"
 
     def __call__(self):
         rendered_items = self.renderItems(self._showData())
-        orientation = self.getValue('orientation')
+        orientation = self.orientation
         if orientation == 'horizontal':
             return "&nbsp;&nbsp;".join(rendered_items)
         else:
@@ -973,7 +970,7 @@
             value = [value]
         name = self.name
         items = self.context.allowed_values
-        cssClass = self.getValue('cssClass')
+        cssClass = self.cssClass
         rendered_items = []
         count = 0
         for item in items:
@@ -1004,7 +1001,7 @@
 
 class MultiListWidget(MultiItemsWidget):
     """List widget with multiple select."""
-    propertyNames = MultiItemsWidget.propertyNames + ['size', 'extra']
+    propertyNames = ['size', 'extra']
     size = 5
 
     def __call__(self):
@@ -1013,10 +1010,10 @@
                               name=self.name,
                               id=self.name,
                               multiple=None,
-                              cssClass=self.getValue('cssClass'),
-                              size=self.getValue('size'),
+                              cssClass=self.cssClass,
+                              size=self.size,
                               contents="\n".join(rendered_items),
-                              extra=self.getValue('extra'))
+                              extra=self.extra)
 
     def renderItem(self, index, text, value, name, cssClass):
         return renderElement('option', contents=text, value=value)
@@ -1028,12 +1025,12 @@
 
 class MultiCheckBoxWidget(MultiItemsWidget):
     """Multiple checkbox widget."""
-    propertyNames = MultiItemsWidget.propertyNames + ['orientation']
+    propertyNames = ['orientation']
     orientation = "vertical"
 
     def __call__(self):
         rendered_items = self.renderItems(self._showData())
-        orientation = self.getValue('orientation')
+        orientation = self.orientation
         if orientation == 'horizontal':
             return "&nbsp;&nbsp;".join(rendered_items)
         else:




More information about the Zope3-Checkins mailing list