[Zope3-checkins] SVN: zope.formlib/branches/faassen-zaf/s Move over registrations from zope.app.form and make sure everything
Martijn Faassen
faassen at startifact.com
Wed Dec 30 17:49:06 EST 2009
Log message for revision 107399:
Move over registrations from zope.app.form and make sure everything
works without zope.app.form.
Changed:
U zope.formlib/branches/faassen-zaf/setup.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/configure.zcml
U zope.formlib/branches/faassen-zaf/src/zope/formlib/objectwidget.txt
U zope.formlib/branches/faassen-zaf/src/zope/formlib/source.txt
A zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/registerWidgets.zcml
U zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_displaywidget.py
A zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_registrations.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_widget.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/widgets.py
-=-
Modified: zope.formlib/branches/faassen-zaf/setup.py
===================================================================
--- zope.formlib/branches/faassen-zaf/setup.py 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/setup.py 2009-12-30 22:49:06 UTC (rev 107399)
@@ -54,7 +54,7 @@
),
install_requires=['setuptools',
'pytz',
- 'zope.app.form',
+# 'zope.app.form',
'zope.browser>=1.1',
'zope.browserpage>=3.11.0',
'zope.component',
@@ -67,6 +67,7 @@
'zope.schema>=3.5.1',
'zope.security',
'zope.traversing',
+ "zope.datetime",
],
include_package_data = True,
zip_safe = False,
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/configure.zcml
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/configure.zcml 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/configure.zcml 2009-12-30 22:49:06 UTC (rev 107399)
@@ -26,4 +26,562 @@
<allow interface=".interfaces.IAction" />
</class>
+ <!-- Views for Widget Errors -->
+
+ <adapter
+ for="zope.formlib.interfaces.IWidgetInputError
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IWidgetInputErrorView"
+ factory=".exception.WidgetInputErrorView"
+ permission="zope.Public"
+ />
+
+ <!-- Core display wfdgets -->
+
+ <adapter
+ for="zope.schema.interfaces.IField
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.DisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBool
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.BooleanDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBytes
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.BytesDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBytesLine
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.DisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IASCII
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ASCIIDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IASCIILine
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.DisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IURI
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.URIDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDate
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.DateDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDatetime
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.DatetimeDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Core edit widgets -->
+
+ <adapter
+ for="zope.schema.interfaces.ITextLine
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ITextBrowserWidget"
+ factory=".widgets.TextWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IText
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.TextAreaWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ISourceText
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.TextAreaWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBytesLine
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.BytesWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBytes
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.FileWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IASCII
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ASCIIAreaWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IASCIILine
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ASCIIWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IInt
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.IntWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IInt
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.UnicodeDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFloat
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.FloatWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFloat
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.UnicodeDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDecimal
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.DecimalWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDecimal
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.UnicodeDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDatetime
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.DatetimeWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IDate
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.DateWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IBool
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.CheckBoxWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IPassword
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.PasswordWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Items-related widgets; they are proxies for the multiviews below. -->
+
+ <!-- Choices (dispatch to field + vocabulary lookup) -->
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ChoiceDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ChoiceInputWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Generic collections (dispatch to field + value_type lookup) -->
+ <adapter
+ for="zope.schema.interfaces.ICollection
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.CollectionDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ICollection
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.CollectionInputWidget"
+ permission="zope.Public"
+ />
+
+ <!--
+
+ Need to repeat the above for Sequence to avoid being overridden by a
+ DAV widget. This suggests that we should be getting something
+ more specific than IInputWidget.
+
+ -->
+ <adapter
+ for="zope.schema.interfaces.ISequence
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.CollectionDisplayWidget"
+ permission="zope.Public"
+ />
+ <adapter
+ for="zope.schema.interfaces.ISequence
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.CollectionInputWidget"
+ permission="zope.Public"
+ />
+
+
+
+ <!-- non-choice collection fields should register for the field + value type
+ so as to allow specific field + value_type widgets such as the Choice
+ pattern -->
+ <adapter
+ for="zope.schema.interfaces.ITuple
+ zope.schema.interfaces.IField
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.TupleSequenceWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IField
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ListSequenceWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ISequence
+ zope.schema.interfaces.IField
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.SequenceDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Choice collections. dispatch to field + vocabulary lookup.
+ We must register the collection + choice factories for all ICollection
+ subclasses because the field (the collection) has precedence: therefore
+ a registration for (IList plus IField) would trump a registration for
+ (ICollection plus IChoice), making choice lists not look up properly.
+ So all new collection types should always register for IChoice if
+ they want to follow in this configuration pattern. -->
+ <!-- List + Choice -->
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ChoiceCollectionDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ChoiceCollectionInputWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Tuple + Choice -->
+ <adapter
+ for="zope.schema.interfaces.ITuple
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ChoiceCollectionDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ITuple
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ChoiceCollectionInputWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Set + Choice -->
+ <adapter
+ for="zope.schema.interfaces.ISet
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ChoiceCollectionDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ISet
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ChoiceCollectionInputWidget"
+ permission="zope.Public"
+ />
+
+ <!-- FrozenSet + Choice -->
+ <adapter
+ for="zope.schema.interfaces.IFrozenSet
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ChoiceCollectionDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFrozenSet
+ zope.schema.interfaces.IChoice
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.ChoiceCollectionInputWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Default Multi-Views for fields and vocabularies -->
+
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.schema.interfaces.IBaseVocabulary
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.ItemDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.schema.interfaces.IVocabularyTokenized
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.DropdownWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Default Multi-Views for fields and iterable sources -->
+
+ <adapter
+ for="zope.schema.interfaces.ISet
+ zope.schema.interfaces.IIterableSource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceMultiSelectSetWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFrozenSet
+ zope.schema.interfaces.IIterableSource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceMultiSelectFrozenSetWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.schema.interfaces.IIterableSource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceDropdownWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IIterableSource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceOrderedMultiSelectWidget"
+ permission="zope.Public"
+ />
+
+ <!-- These widgets are minimal and only support lists with unique members,
+ without ordering capabilities -->
+
+ <adapter
+ for="zope.schema.interfaces.ISet
+ zope.schema.interfaces.IVocabularyTokenized
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.MultiSelectSetWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFrozenSet
+ zope.schema.interfaces.IVocabularyTokenized
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.MultiSelectFrozenSetWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ISet
+ zope.schema.interfaces.IBaseVocabulary
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.SetDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IFrozenSet
+ zope.schema.interfaces.IBaseVocabulary
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.SetDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IVocabularyTokenized
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".widgets.OrderedMultiSelectWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.IBaseVocabulary
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".widgets.SetDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <!-- Source Views -->
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.schema.interfaces.ISource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".source.SourceDisplayWidget"
+ permission="zope.Public"
+ />
+ <adapter
+ for="zope.schema.interfaces.IChoice
+ zope.schema.interfaces.ISource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceInputWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.ISequence
+ zope.schema.interfaces.ISource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".source.SourceSequenceDisplayWidget"
+ permission="zope.Public"
+ />
+
+ <adapter
+ for="zope.schema.interfaces.IAbstractSet
+ zope.schema.interfaces.ISource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.IDisplayWidget"
+ factory=".source.SourceSequenceDisplayWidget"
+ permission="zope.Public"
+ />
+
+
+
+ <!-- TODO We need a widget for tuples (and sets, for that matter). -->
+ <adapter
+ for="zope.schema.interfaces.IList
+ zope.schema.interfaces.ISource
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.formlib.interfaces.ISimpleInputWidget"
+ factory=".source.SourceListInputWidget"
+ permission="zope.Public"
+ />
+
</configure>
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/objectwidget.txt
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/objectwidget.txt 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/objectwidget.txt 2009-12-30 22:49:06 UTC (rev 107399)
@@ -97,8 +97,8 @@
>>> from zope.publisher.browser import TestRequest
>>> from zope.schema.interfaces import ITextLine
>>> from zope.schema import TextLine
- >>> from zope.app.form.browser import TextWidget
- >>> from zope.app.form.browser import ObjectWidget
+ >>> from zope.formlib.widgets import TextWidget
+ >>> from zope.formlib.widgets import ObjectWidget
>>> from zope.formlib.interfaces import IInputWidget
Register the TextLine widget used in the IPerson interface for the field 'name'.
@@ -135,7 +135,7 @@
allready store in the family object, the factory instance will be stored
directly to the family attribute mother. For more information see the method
'applyChanges()' in the interface
-zope.app.form.browser.objectwidget.ObjectWidget.
+zope.formlib.objectwidget.ObjectWidget.
>>> widget.applyChanges(family)
True
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/source.txt
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/source.txt 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/source.txt 2009-12-30 22:49:06 UTC (rev 107399)
@@ -28,7 +28,6 @@
>>> from zope.browser.interfaces import ITerms
>>> import zope.publisher.interfaces.browser
- >>> import zope.app.form.browser.interfaces
>>> from zope.schema.vocabulary import SimpleTerm
>>> class ListTerms:
...
@@ -55,7 +54,7 @@
All of the source widgets are in a single module::
- >>> import zope.app.form.browser.source
+ >>> import zope.formlib.source
We'll also need request objects::
@@ -97,7 +96,7 @@
view directly::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceSelectWidget(
+ >>> widget = zope.formlib.source.SourceSelectWidget(
... dog, dog.source, request)
>>> print widget()
@@ -166,7 +165,7 @@
generates a selection list of size 1::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceDropdownWidget(
+ >>> widget = zope.formlib.source.SourceDropdownWidget(
... dog, dog.source, request)
>>> print widget() # doctest: +ELLIPSIS
<div>
@@ -178,7 +177,7 @@
SourceRadioWidget that provides a radio button group for the items::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceRadioWidget(
+ >>> widget = zope.formlib.source.SourceRadioWidget(
... dog, dog.source, request)
>>> print widget() # doctest: +NORMALIZE_WHITESPACE
<div>
@@ -202,7 +201,7 @@
>>> request.form['field.dog-empty-marker'] = '1'
>>> request.form['field.dog'] = 'bGFzc2ll'
>>>
- >>> widget = zope.app.form.browser.source.SourceRadioWidget(
+ >>> widget = zope.formlib.source.SourceRadioWidget(
... dog, dog.source, request)
>>> print widget() # doctest: +NORMALIZE_WHITESPACE
<div>
@@ -243,7 +242,7 @@
>>> dogs = dogs.bind(object()) # give the field a context
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceMultiSelectWidget(
+ >>> widget = zope.formlib.source.SourceMultiSelectWidget(
... dogs, dogSource, request)
Let's look at the rendered widget::
@@ -301,7 +300,7 @@
An alternative for small numbers of items is to use SourceMultiCheckBoxWidget::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceMultiCheckBoxWidget(
+ >>> widget = zope.formlib.source.SourceMultiCheckBoxWidget(
... dogs, dogSource, request)
The rendered widget::
@@ -376,7 +375,7 @@
For list ordering support, use SourceOrderedMultiSelectWidget::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceOrderedMultiSelectWidget(
+ >>> widget = zope.formlib.source.SourceOrderedMultiSelectWidget(
... dogs, dogSource, request)
The widget is too complicated to show in complete rendered form here.
@@ -433,7 +432,7 @@
... )
>>> dogSet = dogSet.bind(object()) # give the field a context
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceMultiSelectSetWidget(
+ >>> widget = zope.formlib.source.SourceMultiSelectSetWidget(
... dogSet, dogSource, request)
>>> try:
@@ -508,7 +507,7 @@
source itself is assumed to be queriable.
- For each queriable found, a
- `zope.app.form.browser.interfaces.ISourceQueryView` view is looked up. This
+ `zope.formlib.interfaces.ISourceQueryView` view is looked up. This
view is used to obtain the HTML for displaying a query form. The view is also
used to obtain search results.
@@ -531,7 +530,7 @@
>>> class ListQueryView:
...
... zope.interface.implements(
- ... zope.app.form.browser.interfaces.ISourceQueryView)
+ ... zope.formlib.interfaces.ISourceQueryView)
... zope.component.adapts(
... SourceList,
... zope.publisher.interfaces.browser.IBrowserRequest,
@@ -571,7 +570,7 @@
As before, we'll just create the view directly::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceInputWidget(
+ >>> widget = zope.formlib.source.SourceInputWidget(
... dog, dog.source, request)
Now if we render the widget, we'll see the input value (initially nothing) and
@@ -745,7 +744,7 @@
and a widget::
- >>> widget = zope.app.form.browser.source.SourceInputWidget(
+ >>> widget = zope.formlib.source.SourceInputWidget(
... pet, pet.source, request)
Now if we display the widget, we'll see search inputs for both dogs
@@ -875,11 +874,11 @@
values::
>>> request = TestRequest()
- >>> widget = zope.app.form.browser.source.SourceDisplayWidget(
+ >>> widget = zope.formlib.source.SourceDisplayWidget(
... pet, pet.source, request)
>>> print widget()
Nothing
- >>> from zope.app.form.browser.interfaces import IBrowserWidget
+ >>> from zope.formlib.interfaces import IBrowserWidget
>>> IBrowserWidget.providedBy(widget)
True
@@ -901,7 +900,7 @@
and the source, where, in this case, the field is a list field. We'll just call
the widget factory directly::
- >>> widget = zope.app.form.browser.source.SourceListInputWidget(
+ >>> widget = zope.formlib.source.SourceListInputWidget(
... pets, pets.value_type.source, request)
If we render the widget::
@@ -1089,7 +1088,7 @@
... TestTerms,
... (TestSource, zope.publisher.interfaces.browser.IBrowserRequest))
- >>> from zope.app.form.browser.source import IterableSourceVocabulary
+ >>> from zope.formlib.source import IterableSourceVocabulary
>>> request = TestRequest()
>>> vocab = IterableSourceVocabulary(source, request)
>>> from zope.interface.verify import verifyClass, verifyObject
Copied: zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/registerWidgets.zcml (from rev 107362, zope.app.form/branches/faassen-zaf/src/zope/app/form/browser/tests/registerWidgets.zcml)
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/registerWidgets.zcml (rev 0)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/registerWidgets.zcml 2009-12-30 22:49:06 UTC (rev 107399)
@@ -0,0 +1,10 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="zope">
+
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.security" file="meta.zcml" />
+ <include package="zope.browserpage" file="meta.zcml" />
+ <include package="zope.formlib" file="configure.zcml" />
+
+</configure>
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_displaywidget.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_displaywidget.py 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_displaywidget.py 2009-12-30 22:49:06 UTC (rev 107399)
@@ -31,7 +31,7 @@
Like all browser-used widgets, DisplayWidget must implement
`IBrowserWidget`.
- >>> from zope.app.form.browser.interfaces import IBrowserWidget
+ >>> from zope.formlib.interfaces import IBrowserWidget
>>> verifyClass(IBrowserWidget, DisplayWidget)
True
Copied: zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_registrations.py (from rev 107371, zope.app.form/branches/faassen-zaf/src/zope/app/form/browser/tests/test_registrations.py)
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_registrations.py (rev 0)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_registrations.py 2009-12-30 22:49:06 UTC (rev 107399)
@@ -0,0 +1,224 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation 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.
+#
+##############################################################################
+"""Test widget registrations.
+
+$Id$
+"""
+import unittest
+
+from zope.component import getMultiAdapter
+from zope.configuration import xmlconfig
+from zope.interface import implements
+from zope.publisher.browser import TestRequest
+from zope.testing.doctest import DocTestSuite
+
+from zope.component import testing
+# import all widgets (in this case, importing * is ok, since we
+# absolutely know what we're importing)
+from zope.formlib.widgets import *
+
+from zope.formlib.interfaces import IDisplayWidget, IInputWidget
+import zope.formlib
+
+import zope.schema as fields
+from zope.schema import interfaces
+from zope.schema import vocabulary
+
+class ISampleObject(interfaces.IField):
+ pass
+
+class SampleObject(object):
+ implements(ISampleObject)
+
+class ISampleVocabulary(interfaces.IVocabularyTokenized,
+ interfaces.IVocabulary):
+ pass
+
+class SampleVocabulary(vocabulary.SimpleVocabulary):
+ implements(ISampleVocabulary)
+
+request = TestRequest()
+sample = SampleObject()
+vocab = SampleVocabulary([])
+
+def setUp(test):
+ testing.setUp()
+ context = xmlconfig.file("tests/registerWidgets.zcml",
+ zope.formlib)
+
+class Tests(object):
+ """Documents and tests widgets registration for specific field types.
+
+ Standard Widgets
+ ------------------------------------------------------------------------
+ The relationships between field types and standard widgets are listed
+ below.
+
+ IField, IDisplayWidget -> DisplayWidget
+
+ >>> field = fields.Field()
+ >>> widget = getMultiAdapter((field, request), IDisplayWidget)
+ >>> isinstance(widget, DisplayWidget)
+ True
+
+ ITextLine, IInputWidget -> TextWidget
+
+ >>> field = fields.TextLine()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, TextWidget)
+ True
+
+ IText, IInputWidget -> TextAreaWidget
+
+ >>> field = fields.Text()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, TextAreaWidget)
+ True
+
+ ISourceText, IInputWidget -> TextAreaWidget
+
+ >>> field = fields.SourceText()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, TextAreaWidget)
+ True
+
+ IBytesLine, IInputWidget -> BytesWidget
+
+ >>> field = fields.BytesLine()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, BytesWidget)
+ True
+
+ IBytes, IInputWidget -> FileWidget
+
+ >>> field = fields.Bytes()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, FileWidget)
+ True
+
+ IASCIILine, IInputWidget -> ASCIIWidget
+
+ >>> field = fields.ASCIILine()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, ASCIIWidget)
+ True
+
+ IASCII, IInputWidget -> ASCIIAreaWidget
+
+ >>> field = fields.ASCII()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, ASCIIAreaWidget)
+ True
+
+ IInt, IInputWidget -> IntWidget
+
+ >>> field = fields.Int()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, IntWidget)
+ True
+
+ IFloat, IInputWidget -> FloatWidget
+
+ >>> field = fields.Float()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, FloatWidget)
+ True
+
+ IDecimal, IInputWidget -> DecimalWidget
+
+ >>> field = fields.Decimal()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, DecimalWidget)
+ True
+
+ IDatetime, IInputWidget -> DatetimeWidget
+
+ >>> field = fields.Datetime()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, DatetimeWidget)
+ True
+
+ IDate, IInputWidget -> DateWidget
+
+ >>> field = fields.Date()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, DateWidget)
+ True
+
+ IBool, IInputWidget -> CheckBoxWidget
+
+ >>> field = fields.Bool()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, CheckBoxWidget)
+ True
+
+ ITuple, IInputWidget -> TupleSequenceWidget
+
+ >>> field = fields.Tuple(value_type=fields.Int())
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, TupleSequenceWidget)
+ True
+
+ IList, IInputWidget -> ListSequenceWidget
+
+ >>> field = fields.List(value_type=fields.Int())
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, ListSequenceWidget)
+ True
+
+ IPassword, IInputWidget -> PasswordWidget
+
+ >>> field = fields.Password()
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, PasswordWidget)
+ True
+
+ IChoice, IDisplayWidget -> ItemDisplayWidget
+
+ >>> field = fields.Choice(vocabulary=vocab)
+ >>> field = field.bind(sample)
+ >>> widget = getMultiAdapter((field, request), IDisplayWidget)
+ >>> isinstance(widget, ItemDisplayWidget)
+ True
+
+ IChoice, IInputWidget -> DropdownWidget
+
+ >>> field = fields.Choice(vocabulary=vocab)
+ >>> field = field.bind(sample)
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, DropdownWidget)
+ True
+
+ IList with IChoice value_type, IDisplayWidget -> ItemsMultiDisplayWidget
+
+ >>> field = fields.List(value_type=fields.Choice(vocabulary=vocab))
+ >>> field = field.bind(sample)
+ >>> widget = getMultiAdapter((field, request), IDisplayWidget)
+ >>> isinstance(widget, ItemsMultiDisplayWidget)
+ True
+
+ IList with IChoice value_type, IInputWidget -> MultiSelectWidget
+
+ >>> field = fields.List(value_type=fields.Choice(vocabulary=vocab))
+ >>> field = field.bind(sample)
+ >>> widget = getMultiAdapter((field, request), IInputWidget)
+ >>> isinstance(widget, OrderedMultiSelectWidget)
+ True
+ """
+
+def test_suite():
+ return DocTestSuite(setUp=setUp, tearDown=testing.tearDown)
+
+if __name__=='__main__':
+ unittest.main(defaultTest='test_suite')
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_widget.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_widget.py 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/tests/test_widget.py 2009-12-30 22:49:06 UTC (rev 107399)
@@ -173,7 +173,7 @@
Test sequence widget:
>>> from zope.schema import TextLine, List
- >>> from zope.app.form.browser import ListSequenceWidget
+ >>> from zope.formlib.widgets import ListSequenceWidget
>>> value_type = TextLine(__name__=u'bar')
>>> field = List( __name__=u'foo', value_type=value_type )
@@ -197,7 +197,7 @@
Test vocabulary widget:
>>> from zope.schema import Choice
- >>> from zope.app.form.browser import RadioWidget
+ >>> from zope.formlib.widgets import RadioWidget
>>> field = Choice( __name__=u'foo', values=['1', '2', '3'] )
>>> bound = field.bind(context)
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/widgets.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/widgets.py 2009-12-30 22:26:34 UTC (rev 107398)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/widgets.py 2009-12-30 22:49:06 UTC (rev 107399)
@@ -40,6 +40,7 @@
from zope.formlib.boolwidgets import BooleanRadioWidget
from zope.formlib.boolwidgets import BooleanSelectWidget
from zope.formlib.boolwidgets import BooleanDropdownWidget
+from zope.formlib.boolwidgets import BooleanDisplayWidget
# Choice and Sequence Display Widgets
from zope.formlib.itemswidgets import ItemDisplayWidget
More information about the Zope3-Checkins
mailing list