[CMF-checkins] SVN: CMF/trunk/CMFDefault/ - made TupleTextAreaWidget more generic (custom_widget now requires TupleInputWidget)

Yvo Schubbe y.2007- at wcm-solutions.de
Tue Jan 16 08:45:36 EST 2007


Log message for revision 72054:
  - made TupleTextAreaWidget more generic (custom_widget now requires TupleInputWidget)

Changed:
  U   CMF/trunk/CMFDefault/browser/metadata.py
  U   CMF/trunk/CMFDefault/formlib/widgets.py
  U   CMF/trunk/CMFDefault/formlib/widgets.txt

-=-
Modified: CMF/trunk/CMFDefault/browser/metadata.py
===================================================================
--- CMF/trunk/CMFDefault/browser/metadata.py	2007-01-16 13:13:50 UTC (rev 72053)
+++ CMF/trunk/CMFDefault/browser/metadata.py	2007-01-16 13:45:35 UTC (rev 72054)
@@ -37,7 +37,7 @@
 from Products.CMFDefault.formlib.schema import SchemaAdapterBase
 from Products.CMFDefault.formlib.vocabulary import SimpleVocabulary
 from Products.CMFDefault.formlib.widgets import SubjectInputWidget
-from Products.CMFDefault.formlib.widgets import TupleTextAreaWidget
+from Products.CMFDefault.formlib.widgets import TupleInputWidget
 from Products.CMFDefault.utils import Message as _
 
 available_settings = [
@@ -239,7 +239,7 @@
 
     form_fields = form.FormFields(IMetadataSchema)
     form_fields['subject'].custom_widget = SubjectInputWidget
-    form_fields['contributors'].custom_widget = TupleTextAreaWidget
+    form_fields['contributors'].custom_widget = TupleInputWidget
     form_fields['effective'].custom_widget = DatetimeI18nWidget
     form_fields['expires'].custom_widget = DatetimeI18nWidget
 

Modified: CMF/trunk/CMFDefault/formlib/widgets.py
===================================================================
--- CMF/trunk/CMFDefault/formlib/widgets.py	2007-01-16 13:13:50 UTC (rev 72053)
+++ CMF/trunk/CMFDefault/formlib/widgets.py	2007-01-16 13:45:35 UTC (rev 72054)
@@ -57,6 +57,9 @@
     implementsOnly(IInputWidget)
     adapts(ITuple, IBrowserRequest)
 
+    def __init__(self, context, field, request):
+        super(TupleTextAreaWidget, self).__init__(context, request)
+
     def _toFieldValue(self, input):
         input = super(TupleTextAreaWidget, self)._toFieldValue(input)
         if isinstance(input, basestring):
@@ -74,6 +77,10 @@
         return super(TupleTextAreaWidget, self)._toFormValue(value)
 
 
+def TupleInputWidget(field, request):
+    return TupleTextAreaWidget(field, field.value_type, request)
+
+
 class SubjectInputWidget(InputWidget, BrowserWidget):
 
     implementsOnly(IInputWidget)
@@ -106,7 +113,7 @@
                 self._widgets[0] = widget
             elif i == 1:
                 field = Tuple(__name__='', required=False).bind(self.context)
-                widget = TupleTextAreaWidget(field, self.request)
+                widget = TupleInputWidget(field, self.request)
                 widget.name = self.name
                 widget.height = self.vocabulary and 2 or 6
                 self._widgets[1] = widget

Modified: CMF/trunk/CMFDefault/formlib/widgets.txt
===================================================================
--- CMF/trunk/CMFDefault/formlib/widgets.txt	2007-01-16 13:13:50 UTC (rev 72053)
+++ CMF/trunk/CMFDefault/formlib/widgets.txt	2007-01-16 13:45:35 UTC (rev 72054)
@@ -13,12 +13,12 @@
       >>> request = DummyRequest()
       >>> request.form['PREFIX.NAME'] = u'FOO \n BAR'
 
-      >>> from Products.CMFDefault.formlib.widgets import TupleTextAreaWidget
+      >>> from Products.CMFDefault.formlib.widgets import TupleInputWidget
       >>> from zope.schema import Tuple
       >>> tuple_field = Tuple(__name__='NAME', title=u'FIELD TITLE',
       ...                     required=False)
 
-      >>> widget = TupleTextAreaWidget(tuple_field, request)
+      >>> widget = TupleInputWidget(tuple_field, request)
 
     IWidget::
 



More information about the CMF-checkins mailing list