[Checkins] SVN: z3c.form/trunk/src/z3c/form/ - implemented (optional) hint concept based on schema field description used as widget title value.

Roger Ineichen roger at projekt01.ch
Wed Oct 1 01:13:41 EDT 2008


Log message for revision 91646:
  - implemented (optional) hint concept based on schema field description used as widget title value.
    If you like to use that hint concept, just configure the FieldDescriptionAsHint adapter.
  - added another 600+ lines of test and samples for hints in widgets
  - enhance setupFormDefaults, support more widgets and data converter by default

Changed:
  A   z3c.form/trunk/src/z3c/form/hint.py
  A   z3c.form/trunk/src/z3c/form/hint.txt
  U   z3c.form/trunk/src/z3c/form/testing.py
  U   z3c.form/trunk/src/z3c/form/tests/test_doc.py
  U   z3c.form/trunk/src/z3c/form/widget.py

-=-
Added: z3c.form/trunk/src/z3c/form/hint.py
===================================================================
--- z3c.form/trunk/src/z3c/form/hint.py	                        (rev 0)
+++ z3c.form/trunk/src/z3c/form/hint.py	2008-10-01 05:13:40 UTC (rev 91646)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Title hint adapter implementation
+
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.component
+import zope.schema.interfaces
+
+from z3c.form import interfaces
+
+
+class FieldDescriptionAsHint(object):
+    """Schema field description as widget ``title`` IValue adapter."""
+
+    zope.interface.implements(interfaces.IValue)
+    zope.component.adapts(zope.interface.Interface, interfaces.IFormLayer,
+        interfaces.IForm, zope.schema.interfaces.IField, interfaces.IWidget) 
+
+    def __init__(self, context, request, form, field, widget):
+        self.context = context
+        self.request = request
+        self.form = form
+        self.field = field
+        self.widget = widget
+
+    def get(self):
+        if self.field.description:
+            return self.field.description
+        # None avoids rendering in templates
+        return None
+
+    def __repr__(self):
+        return '<%s %r>' % (self.__class__.__name__, self.__name__)


Property changes on: z3c.form/trunk/src/z3c/form/hint.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.form/trunk/src/z3c/form/hint.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/hint.txt	                        (rev 0)
+++ z3c.form/trunk/src/z3c/form/hint.txt	2008-10-01 05:13:40 UTC (rev 91646)
@@ -0,0 +1,638 @@
+========================
+Hint (title) Adapters
+========================
+
+A widget can provide a hint. Hints are not a standard concept, the 
+implementations can be very different in each project. Hints are most the time
+implemented with JavaScript since the default ``input title`` hint in browsers
+ar almost unusable.
+
+Our hint support is limited and only offers some helpers. Which means we will
+offer an adapter for show the schema field description as title. Since this
+is very specific we only provide a ``FieldDescriptionAsHint`` adapter which
+you can configure as named IValue adapter.
+
+  >>> import zope.interface
+  >>> import zope.component
+  >>> from z3c.form import form
+  >>> from z3c.form import field
+  >>> from z3c.form import hint
+
+We also need to setup the form defaults:
+
+  >>> from z3c.form import testing
+  >>> testing.setupFormDefaults()
+
+Let's create a couple of simple widgets and forms first:
+
+  >>> class IContent(zope.interface.Interface):
+  ... 
+  ...     textLine = zope.schema.TextLine(
+  ...         title=u'Title',
+  ...         description=u'A TextLine description')
+
+  >>> class Content(object):
+  ...     zope.interface.implements(IContent)
+  ... 
+  ...     textLine = None
+  ... 
+  >>> content = Content()
+
+  >>> from z3c.form.testing import TestRequest
+  >>> request = TestRequest()
+
+  >>> class HintForm(form.Form):
+  ...     fields = field.Fields(IContent)
+
+  >>> hintForm = HintForm(content, request)
+
+As you can see, there is no title value set for our widget:
+
+  >>> hintForm.update()
+  >>> print hintForm.widgets['textLine'].render()
+  <input id="form-widgets-textLine"
+         name="form.widgets.textLine"
+         class="text-widget required textline-field"
+         value="" type="text" />
+
+Let's configure our IValue ``hint`` adapter:
+
+  >>> from z3c.form.hint import FieldDescriptionAsHint
+  >>> zope.component.provideAdapter(FieldDescriptionAsHint, name='title')
+
+If we update our form, we can see that the title is used based on the schema
+field description:
+
+  >>> hintForm.update()
+  >>> print hintForm.widgets['textLine'].render()
+  <input id="form-widgets-textLine"
+         name="form.widgets.textLine"
+         class="text-widget required textline-field"
+         title="A TextLine description" value=""
+         type="text" />
+
+
+Check all fields
+----------------
+
+Just make sure that all widgets get correct handled. This sample can be useful 
+if you need to implement a JavaScript based hint concept:
+
+  >>> import datetime
+  >>> import decimal
+  >>> from zope.schema import vocabulary
+
+Let's setup a sample vocabulary:
+
+  >>> vocab = vocabulary.SimpleVocabulary([
+  ...     vocabulary.SimpleVocabulary.createTerm(1, '1', u'One'),
+  ...     vocabulary.SimpleVocabulary.createTerm(2, '2', u'Two'),
+  ...     vocabulary.SimpleVocabulary.createTerm(3, '3', u'Three'),
+  ...     vocabulary.SimpleVocabulary.createTerm(4, '4', u'Four'),
+  ...     vocabulary.SimpleVocabulary.createTerm(5, '5', u'Five')
+  ...     ])
+
+  >>> class IAllInOne(zope.interface.Interface):
+  ... 
+  ...     asciiField = zope.schema.ASCII(
+  ...         title=u'ASCII',
+  ...         description=u'This is an ASCII field.',
+  ...         default='This is\n ASCII.')
+  ... 
+  ...     asciiLineField = zope.schema.ASCIILine(
+  ...         title=u'ASCII Line',
+  ...         description=u'This is an ASCII-Line field.',
+  ...         default='An ASCII line.')
+  ... 
+  ...     boolField = zope.schema.Bool(
+  ...         title=u'Boolean',
+  ...         description=u'This is a Bool field.',
+  ...         default=True)
+  ... 
+  ...     checkboxBoolField = zope.schema.Bool(
+  ...         title=u'Boolean (Checkbox)',
+  ...         description=u'This is a Bool field displayed suing a checkbox.',
+  ...         default=True)
+  ... 
+  ...     bytesLineField = zope.schema.BytesLine(
+  ...         title=u'Bytes Line',
+  ...         description=u'This is a bytes line field.',
+  ...         default='A Bytes line.')
+  ... 
+  ...     choiceField = zope.schema.Choice(
+  ...         title=u'Choice',
+  ...         description=u'This is a choice field.',
+  ...         default=3,
+  ...         vocabulary=vocab)
+  ... 
+  ...     optionalChoiceField = zope.schema.Choice(
+  ...         title=u'Choice (Not Required)',
+  ...         description=u'This is a non-required choice field.',
+  ...         vocabulary=vocab,
+  ...         required=False)
+  ... 
+  ...     promptChoiceField = zope.schema.Choice(
+  ...         title=u'Choice (Explicit Prompt)',
+  ...         description=u'This is a choice field with an explicit prompt.',
+  ...         vocabulary=vocab,
+  ...         required=False)
+  ... 
+  ...     dateField = zope.schema.Date(
+  ...         title=u'Date',
+  ...         description=u'This is a Date field.',
+  ...         default=datetime.date(2007, 4, 1))
+  ... 
+  ...     datetimeField = zope.schema.Datetime(
+  ...         title=u'Date/Time',
+  ...         description=u'This is a Datetime field.',
+  ...         default=datetime.datetime(2007, 4, 1, 12))
+  ... 
+  ...     decimalField = zope.schema.Decimal(
+  ...         title=u'Decimal',
+  ...         description=u'This is a Decimal field.',
+  ...         default=decimal.Decimal('12.87'))
+  ... 
+  ...     dottedNameField = zope.schema.DottedName(
+  ...         title=u'Dotted Name',
+  ...         description=u'This is a DottedName field.',
+  ...         default='z3c.form')
+  ... 
+  ...     floatField = zope.schema.Float(
+  ...         title=u'Float',
+  ...         description=u'This is a Float field.',
+  ...         default=12.8)
+  ... 
+  ...     frozenSetField = zope.schema.FrozenSet(
+  ...         title=u'Frozen Set',
+  ...         description=u'This is a FrozenSet field.',
+  ...         value_type=choiceField,
+  ...         default=frozenset([1, 3]) )
+  ... 
+  ...     idField = zope.schema.Id(
+  ...         title=u'Id',
+  ...         description=u'This is a Id field.',
+  ...         default='z3c.form')
+  ... 
+  ...     intField = zope.schema.Int(
+  ...         title=u'Integer',
+  ...         description=u'This is a Int field.',
+  ...         default=12345)
+  ... 
+  ...     listField = zope.schema.List(
+  ...         title=u'List',
+  ...         description=u'This is a List field.',
+  ...         value_type=choiceField,
+  ...         default=[1, 3])
+  ... 
+  ...     passwordField = zope.schema.Password(
+  ...         title=u'Password',
+  ...         description=u'This is a Password field.',
+  ...         default=u'mypwd',
+  ...         required=False)
+  ... 
+  ...     setField = zope.schema.Set(
+  ...         title=u'Set',
+  ...         description=u'This is a Set field.',
+  ...         value_type=choiceField,
+  ...         default=set([1, 3]) )
+  ... 
+  ...     sourceTextField = zope.schema.SourceText(
+  ...         title=u'Source Text',
+  ...         description=u'This is a SourceText field.',
+  ...         default=u'<source />')
+  ... 
+  ...     textField = zope.schema.Text(
+  ...         title=u'Text',
+  ...         description=u'This is a Text field.',
+  ...         default=u'Some\n Text.')
+  ... 
+  ...     textLineField = zope.schema.TextLine(
+  ...         title=u'Text Line',
+  ...         description=u'This is a TextLine field.',
+  ...         default=u'Some Text line.')
+  ... 
+  ...     timeField = zope.schema.Time(
+  ...         title=u'Time',
+  ...         description=u'This is a Time field.',
+  ...         default=datetime.time(12, 0))
+  ... 
+  ...     timedeltaField = zope.schema.Timedelta(
+  ...         title=u'Time Delta',
+  ...         description=u'This is a Timedelta field.',
+  ...         default=datetime.timedelta(days=3))
+  ... 
+  ...     tupleField = zope.schema.Tuple(
+  ...         title=u'Tuple',
+  ...         description=u'This is a Tuple field.',
+  ...         value_type=choiceField,
+  ...         default=(1, 3))
+  ... 
+  ...     uriField = zope.schema.URI(
+  ...         title=u'URI',
+  ...         description=u'This is a URI field.',
+  ...         default='http://zope.org')
+  ... 
+  ...     hiddenField = zope.schema.TextLine(
+  ...         title=u'Hidden Text Line',
+  ...         description=u'This is a hidden TextLine field.',
+  ...         default=u'Some Hidden Text.')
+
+  >>> class AllInOne(object):
+  ...     zope.interface.implements(IAllInOne)
+  ... 
+  ...     asciiField = None
+  ...     asciiLineField = None
+  ...     boolField = None
+  ...     checkboxBoolField = None
+  ...     choiceField = None
+  ...     optionalChoiceField = None
+  ...     promptChoiceField = None
+  ...     dateField = None
+  ...     decimalField = None
+  ...     dottedNameField = None
+  ...     floatField = None
+  ...     frozenSetField = None
+  ...     idField = None
+  ...     intField = None
+  ...     listField = None
+  ...     passwordField = None
+  ...     setField = None
+  ...     sourceTextField = None
+  ...     textField = None
+  ...     textLineField = None
+  ...     timeField = None
+  ...     timedeltaField = None
+  ...     tupleField = None
+  ...     uriField = None
+  ...     hiddenField = None
+
+  >>> allInOne = AllInOne()
+
+  >>> class AllInOneForm(form.Form):
+  ...     fields = field.Fields(IAllInOne)
+
+Now test the hints in our widgets:
+
+  >>> allInOneForm = AllInOneForm(allInOne, request)
+  >>> allInOneForm.update()
+  >>> print allInOneForm.widgets['asciiField'].render()
+  <textarea id="form-widgets-asciiField"
+            name="form.widgets.asciiField"
+            class="textarea-widget required ascii-field"
+            title="This is an ASCII field.">This is
+   ASCII.</textarea>
+
+  >>> print allInOneForm.widgets['asciiLineField'].render()
+  <input id="form-widgets-asciiLineField"
+         name="form.widgets.asciiLineField"
+         class="text-widget required asciiline-field"
+         title="This is an ASCII-Line field."
+         value="An ASCII line." type="text" />
+
+  >>> print allInOneForm.widgets['boolField'].render()
+  <span class="option">
+    <label for="form-widgets-boolField-0">
+      <input id="form-widgets-boolField-0"
+             name="form.widgets.boolField:list"
+             class="radio-widget required bool-field"
+             title="This is a Bool field." value="true"
+             checked="checked" type="radio" />
+      <span class="label">yes</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-boolField-1">
+      <input id="form-widgets-boolField-1"
+             name="form.widgets.boolField:list"
+             class="radio-widget required bool-field"
+             title="This is a Bool field." value="false"
+             type="radio" />
+      <span class="label">no</span>
+    </label>
+  </span>
+  <input name="form.widgets.boolField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['checkboxBoolField'].render()
+  <span class="option">
+    <label for="form-widgets-checkboxBoolField-0">
+      <input id="form-widgets-checkboxBoolField-0"
+             name="form.widgets.checkboxBoolField:list"
+             class="radio-widget required bool-field"
+             title="This is a Bool field displayed suing a checkbox."
+             value="true" checked="checked" type="radio" />
+      <span class="label">yes</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-checkboxBoolField-1">
+      <input id="form-widgets-checkboxBoolField-1"
+             name="form.widgets.checkboxBoolField:list"
+             class="radio-widget required bool-field"
+             title="This is a Bool field displayed suing a checkbox."
+             value="false" type="radio" />
+      <span class="label">no</span>
+    </label>
+  </span>
+  <input name="form.widgets.checkboxBoolField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['bytesLineField'].render()
+  <input id="form-widgets-bytesLineField"
+         name="form.widgets.bytesLineField"
+         class="text-widget required bytesline-field"
+         title="This is a bytes line field."
+         value="A Bytes line." type="text" />
+
+  >>> print allInOneForm.widgets['choiceField'].render()
+  <select id="form-widgets-choiceField"
+          name="form.widgets.choiceField:list"
+          class="select-widget required choice-field" size="1"
+          title="This is a choice field.">
+  <option id="form-widgets-choiceField-0" value="1">One</option>
+  <option id="form-widgets-choiceField-1" value="2">Two</option>
+  <option id="form-widgets-choiceField-2" value="3"
+          selected="selected">Three</option>
+  <option id="form-widgets-choiceField-3" value="4">Four</option>
+  <option id="form-widgets-choiceField-4" value="5">Five</option>
+  </select>
+  <input name="form.widgets.choiceField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['optionalChoiceField'].render()
+  <select id="form-widgets-optionalChoiceField"
+          name="form.widgets.optionalChoiceField:list"
+          class="select-widget choice-field" size="1"
+          title="This is a non-required choice field.">
+  <option id="form-widgets-optionalChoiceField-novalue"
+          value="--NOVALUE--" selected="selected">no value</option>
+  <option id="form-widgets-optionalChoiceField-0" value="1">One</option>
+  <option id="form-widgets-optionalChoiceField-1" value="2">Two</option>
+  <option id="form-widgets-optionalChoiceField-2" value="3">Three</option>
+  <option id="form-widgets-optionalChoiceField-3" value="4">Four</option>
+  <option id="form-widgets-optionalChoiceField-4" value="5">Five</option>
+  </select>
+  <input name="form.widgets.optionalChoiceField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['promptChoiceField'].render()
+  <select id="form-widgets-promptChoiceField"
+          name="form.widgets.promptChoiceField:list"
+          class="select-widget choice-field" size="1"
+          title="This is a choice field with an explicit prompt.">
+  <option id="form-widgets-promptChoiceField-novalue"
+          value="--NOVALUE--" selected="selected">no value</option>
+  <option id="form-widgets-promptChoiceField-0" value="1">One</option>
+  <option id="form-widgets-promptChoiceField-1" value="2">Two</option>
+  <option id="form-widgets-promptChoiceField-2" value="3">Three</option>
+  <option id="form-widgets-promptChoiceField-3" value="4">Four</option>
+  <option id="form-widgets-promptChoiceField-4" value="5">Five</option>
+  </select>
+  <input name="form.widgets.promptChoiceField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['dateField'].render()
+  <input id="form-widgets-dateField"
+         name="form.widgets.dateField"
+         class="text-widget required date-field"
+         title="This is a Date field." value="07/04/01"
+         type="text" />
+
+  >>> print allInOneForm.widgets['datetimeField'].render()
+  <input id="form-widgets-datetimeField"
+         name="form.widgets.datetimeField"
+         class="text-widget required datetime-field"
+         title="This is a Datetime field."
+         value="07/04/01 12:00" type="text" />
+
+  >>> print allInOneForm.widgets['decimalField'].render()
+  <input id="form-widgets-decimalField"
+         name="form.widgets.decimalField"
+         class="text-widget required decimal-field"
+         title="This is a Decimal field." value="12.87"
+         type="text" />
+
+  >>> print allInOneForm.widgets['dottedNameField'].render()
+  <input id="form-widgets-dottedNameField"
+         name="form.widgets.dottedNameField"
+         class="text-widget required dottedname-field"
+         title="This is a DottedName field."
+         value="z3c.form" type="text" />
+
+  >>> print allInOneForm.widgets['floatField'].render()
+  <input id="form-widgets-floatField"
+         name="form.widgets.floatField"
+         class="text-widget required float-field"
+         title="This is a Float field." value="12.8"
+         type="text" />
+
+  >>> print allInOneForm.widgets['frozenSetField'].render()
+  <select id="form-widgets-frozenSetField"
+          name="form.widgets.frozenSetField:list"
+          class="select-widget required frozenset-field"
+          multiple="multiple" size="5"
+          title="This is a FrozenSet field.">
+  <option id="form-widgets-frozenSetField-0" value="1"
+          selected="selected">One</option>
+  <option id="form-widgets-frozenSetField-1" value="2">Two</option>
+  <option id="form-widgets-frozenSetField-2" value="3"
+          selected="selected">Three</option>
+  <option id="form-widgets-frozenSetField-3" value="4">Four</option>
+  <option id="form-widgets-frozenSetField-4" value="5">Five</option>
+  </select>
+  <input name="form.widgets.frozenSetField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['idField'].render()
+  <input id="form-widgets-idField"
+         name="form.widgets.idField"
+         class="text-widget required id-field"
+         title="This is a Id field." value="z3c.form"
+         type="text" />
+
+  >>> print allInOneForm.widgets['intField'].render()
+  <input id="form-widgets-intField"
+         name="form.widgets.intField"
+         class="text-widget required int-field"
+         title="This is a Int field." value="12,345"
+         type="text" />
+
+  >>> print allInOneForm.widgets['listField'].render()
+  <span class="option">
+    <label for="form-widgets-listField-0">
+      <input id="form-widgets-listField-0"
+             name="form.widgets.listField:list"
+             class="radio-widget required list-field"
+             title="This is a List field." value="1"
+             checked="checked" type="radio" />
+      <span class="label">One</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-listField-1">
+      <input id="form-widgets-listField-1"
+             name="form.widgets.listField:list"
+             class="radio-widget required list-field"
+             title="This is a List field." value="2"
+             type="radio" />
+      <span class="label">Two</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-listField-2">
+      <input id="form-widgets-listField-2"
+             name="form.widgets.listField:list"
+             class="radio-widget required list-field"
+             title="This is a List field." value="3"
+             checked="checked" type="radio" />
+      <span class="label">Three</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-listField-3">
+      <input id="form-widgets-listField-3"
+             name="form.widgets.listField:list"
+             class="radio-widget required list-field"
+             title="This is a List field." value="4"
+             type="radio" />
+      <span class="label">Four</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-listField-4">
+      <input id="form-widgets-listField-4"
+             name="form.widgets.listField:list"
+             class="radio-widget required list-field"
+             title="This is a List field." value="5"
+             type="radio" />
+      <span class="label">Five</span>
+    </label>
+  </span>
+  <input name="form.widgets.listField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['passwordField'].render()
+  <input id="form-widgets-passwordField"
+         name="form.widgets.passwordField"
+         class="text-widget password-field"
+         title="This is a Password field." value="mypwd"
+         type="text" />
+
+  >>> print allInOneForm.widgets['setField'].render()
+  <select id="form-widgets-setField"
+          name="form.widgets.setField:list"
+          class="select-widget required set-field"
+          multiple="multiple" size="5"
+          title="This is a Set field.">
+  <option id="form-widgets-setField-0" value="1"
+          selected="selected">One</option>
+  <option id="form-widgets-setField-1" value="2">Two</option>
+  <option id="form-widgets-setField-2" value="3"
+          selected="selected">Three</option>
+  <option id="form-widgets-setField-3" value="4">Four</option>
+  <option id="form-widgets-setField-4" value="5">Five</option>
+  </select>
+  <input name="form.widgets.setField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['sourceTextField'].render()
+  <textarea id="form-widgets-sourceTextField"
+            name="form.widgets.sourceTextField"
+            class="textarea-widget required sourcetext-field"
+            title="This is a SourceText field.">&lt;source /&gt;</textarea>
+
+  >>> print allInOneForm.widgets['textField'].render()
+  <textarea id="form-widgets-textField"
+            name="form.widgets.textField"
+            class="textarea-widget required text-field"
+            title="This is a Text field.">Some
+   Text.</textarea>
+
+  >>> print allInOneForm.widgets['textLineField'].render()
+  <input id="form-widgets-textLineField"
+         name="form.widgets.textLineField"
+         class="text-widget required textline-field"
+         title="This is a TextLine field."
+         value="Some Text line." type="text" />
+
+  >>> print allInOneForm.widgets['timeField'].render()
+  <input id="form-widgets-timeField"
+         name="form.widgets.timeField"
+         class="text-widget required time-field"
+         title="This is a Time field." value="12:00"
+         type="text" />
+ 
+  >>> print allInOneForm.widgets['timedeltaField'].render()
+  <input id="form-widgets-timedeltaField"
+         name="form.widgets.timedeltaField"
+         class="text-widget required timedelta-field"
+         title="This is a Timedelta field."
+         value="3 days, 0:00:00" type="text" />
+
+  >>> print allInOneForm.widgets['tupleField'].render()
+  <span class="option">
+    <label for="form-widgets-tupleField-0">
+      <input id="form-widgets-tupleField-0"
+             name="form.widgets.tupleField:list"
+             class="radio-widget required tuple-field"
+             title="This is a Tuple field." value="1"
+             checked="checked" type="radio" />
+      <span class="label">One</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-tupleField-1">
+      <input id="form-widgets-tupleField-1"
+             name="form.widgets.tupleField:list"
+             class="radio-widget required tuple-field"
+             title="This is a Tuple field." value="2"
+             type="radio" />
+      <span class="label">Two</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-tupleField-2">
+      <input id="form-widgets-tupleField-2"
+             name="form.widgets.tupleField:list"
+             class="radio-widget required tuple-field"
+             title="This is a Tuple field." value="3"
+             checked="checked" type="radio" />
+      <span class="label">Three</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-tupleField-3">
+      <input id="form-widgets-tupleField-3"
+             name="form.widgets.tupleField:list"
+             class="radio-widget required tuple-field"
+             title="This is a Tuple field." value="4"
+             type="radio" />
+      <span class="label">Four</span>
+    </label>
+  </span>
+  <span class="option">
+    <label for="form-widgets-tupleField-4">
+      <input id="form-widgets-tupleField-4"
+             name="form.widgets.tupleField:list"
+             class="radio-widget required tuple-field"
+             title="This is a Tuple field." value="5"
+             type="radio" />
+      <span class="label">Five</span>
+    </label>
+  </span>
+  <input name="form.widgets.tupleField-empty-marker"
+         type="hidden" value="1" />
+
+  >>> print allInOneForm.widgets['uriField'].render()
+  <input id="form-widgets-uriField"
+         name="form.widgets.uriField"
+         class="text-widget required uri-field"
+         title="This is a URI field."
+         value="http://zope.org" type="text" />
+
+  >>> print allInOneForm.widgets['hiddenField'].render()
+  <input id="form-widgets-hiddenField"
+         name="form.widgets.hiddenField"
+         class="text-widget required textline-field"
+         title="This is a hidden TextLine field."
+         value="Some Hidden Text." type="text" />


Property changes on: z3c.form/trunk/src/z3c/form/hint.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.form/trunk/src/z3c/form/testing.py
===================================================================
--- z3c.form/trunk/src/z3c/form/testing.py	2008-10-01 05:06:10 UTC (rev 91645)
+++ z3c.form/trunk/src/z3c/form/testing.py	2008-10-01 05:13:40 UTC (rev 91646)
@@ -37,7 +37,8 @@
 
 from z3c.form import browser, button, converter, datamanager, error, field
 from z3c.form import form, interfaces, term, validator, widget
-from z3c.form.browser import radio, select, text
+from z3c.form.browser import radio, select, text, textarea
+from z3c.form.browser import file as fileWidget
 
 import z3c.pt.compat
 
@@ -173,14 +174,41 @@
     # Text Field Widget
     zope.component.provideAdapter(
         text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IBytesLine, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IASCIILine, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
         adapts=(zope.schema.interfaces.ITextLine, interfaces.IFormLayer))
     zope.component.provideAdapter(
         text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IId, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
         adapts=(zope.schema.interfaces.IInt, interfaces.IFormLayer))
     zope.component.provideAdapter(
         text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IFloat, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
         adapts=(zope.schema.interfaces.IDecimal, interfaces.IFormLayer))
     zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IDate, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IDatetime, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.ITime, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.ITimedelta, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        text.TextFieldWidget,
+        adapts=(zope.schema.interfaces.IURI, interfaces.IFormLayer))
+    zope.component.provideAdapter(
         widget.WidgetTemplateFactory(getPath('text_input.pt'), 'text/html'),
         (None, None, None, None, interfaces.ITextWidget),
         IPageTemplate, name=interfaces.INPUT_MODE)
@@ -192,6 +220,23 @@
         widget.WidgetTemplateFactory(getPath('text_hidden.pt'), 'text/html'),
         (None, None, None, None, interfaces.ITextWidget),
         IPageTemplate, name=interfaces.HIDDEN_MODE)
+
+    # Textarea Field Widget
+    zope.component.provideAdapter(
+        textarea.TextAreaFieldWidget,
+        adapts=(zope.schema.interfaces.IASCII, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        textarea.TextAreaFieldWidget,
+        adapts=(zope.schema.interfaces.IText, interfaces.IFormLayer))
+    zope.component.provideAdapter(
+        widget.WidgetTemplateFactory(getPath('textarea_input.pt'), 'text/html'),
+        (None, None, None, None, interfaces.ITextAreaWidget),
+        IPageTemplate, name=interfaces.INPUT_MODE)
+    zope.component.provideAdapter(
+        widget.WidgetTemplateFactory(getPath('textarea_display.pt'), 'text/html'),
+        (None, None, None, None, interfaces.ITextAreaWidget),
+        IPageTemplate, name=interfaces.DISPLAY_MODE)
+
     # Radio Field Widget
     zope.component.provideAdapter(radio.RadioFieldWidget)
     zope.component.provideAdapter(
@@ -202,7 +247,8 @@
         widget.WidgetTemplateFactory(getPath('radio_display.pt'), 'text/html'),
         (None, None, None, None, interfaces.IRadioWidget),
         IPageTemplate, name=interfaces.DISPLAY_MODE)
-    # Select Field Widget
+
+    # Select Widget
     zope.component.provideAdapter(select.SelectFieldWidget)
     zope.component.provideAdapter(
         widget.WidgetTemplateFactory(getPath('select_input.pt'), 'text/html'),
@@ -216,6 +262,7 @@
         widget.WidgetTemplateFactory(getPath('select_hidden.pt'), 'text/html'),
         (None, None, None, None, interfaces.ISelectWidget),
         IPageTemplate, name=interfaces.HIDDEN_MODE)
+
     # Checkbox Field Widget; register only templates
     zope.component.provideAdapter(
         widget.WidgetTemplateFactory(getPath('checkbox_input.pt'), 'text/html'),
@@ -239,9 +286,18 @@
     zope.component.provideAdapter(converter.SequenceDataConverter)
     zope.component.provideAdapter(converter.CollectionSequenceDataConverter)
     zope.component.provideAdapter(converter.FieldWidgetDataConverter)
+    # special data converter
+    zope.component.provideAdapter(converter.IntegerDataConverter)
+    zope.component.provideAdapter(converter.FloatDataConverter)
+    zope.component.provideAdapter(converter.DecimalDataConverter)
+    zope.component.provideAdapter(converter.DateDataConverter)
+    zope.component.provideAdapter(converter.TimeDataConverter)
+    zope.component.provideAdapter(converter.DatetimeDataConverter)
+    zope.component.provideAdapter(converter.TimedeltaDataConverter)
     # Adapter for providing terms to radio list and other widgets
+    zope.component.provideAdapter(term.BoolTerms)
     zope.component.provideAdapter(term.ChoiceTerms)
-    zope.component.provideAdapter(term.BoolTerms)
+    zope.component.provideAdapter(term.CollectionTerms)
     # Adapter to create an action from a button
     zope.component.provideAdapter(
         button.ButtonAction, provides=interfaces.IButtonAction)

Modified: z3c.form/trunk/src/z3c/form/tests/test_doc.py
===================================================================
--- z3c.form/trunk/src/z3c/form/tests/test_doc.py	2008-10-01 05:06:10 UTC (rev 91645)
+++ z3c.form/trunk/src/z3c/form/tests/test_doc.py	2008-10-01 05:13:40 UTC (rev 91646)
@@ -134,6 +134,12 @@
             setUp=setUp, tearDown=testing.tearDown,
             optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
             checker=checker,
+            ),
+        doctest.DocFileSuite(
+            '../hint.txt',
+            setUp=setUp, tearDown=testing.tearDown,
+            optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+            checker=checker,
             ))
         for setUp in (testing.setUpZPT, testing.setUpZ3CPT))
 

Modified: z3c.form/trunk/src/z3c/form/widget.py
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.py	2008-10-01 05:06:10 UTC (rev 91645)
+++ z3c.form/trunk/src/z3c/form/widget.py	2008-10-01 05:13:40 UTC (rev 91646)
@@ -65,7 +65,7 @@
     field = None
 
     # Internal attributes
-    _adapterValueAttributes = ('label', 'name', 'required')
+    _adapterValueAttributes = ('label', 'name', 'required', 'title')
 
     def __init__(self, request):
         self.request = request



More information about the Checkins mailing list