[Zope3-checkins] SVN: zope.formlib/branches/faassen-zaf/ Switch over to use zope.formlibwidget.
Martijn Faassen
faassen at startifact.com
Wed Dec 30 12:39:19 EST 2009
Log message for revision 107365:
Switch over to use zope.formlibwidget.
Changed:
U zope.formlib/branches/faassen-zaf/buildout.cfg
U zope.formlib/branches/faassen-zaf/setup.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/bugs.txt
U zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.txt
U zope.formlib/branches/faassen-zaf/src/zope/formlib/form.py
U zope.formlib/branches/faassen-zaf/src/zope/formlib/form.txt
U zope.formlib/branches/faassen-zaf/src/zope/formlib/tests.py
-=-
Modified: zope.formlib/branches/faassen-zaf/buildout.cfg
===================================================================
--- zope.formlib/branches/faassen-zaf/buildout.cfg 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/buildout.cfg 2009-12-30 17:39:18 UTC (rev 107365)
@@ -1,5 +1,5 @@
[buildout]
-develop = .
+develop = . ../zope.formlibwidget
parts = test python
[test]
Modified: zope.formlib/branches/faassen-zaf/setup.py
===================================================================
--- zope.formlib/branches/faassen-zaf/setup.py 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/setup.py 2009-12-30 17:39:18 UTC (rev 107365)
@@ -54,7 +54,7 @@
),
install_requires=['setuptools',
'pytz',
- 'zope.app.form',
+ 'zope.formlibwidget',
'zope.browser>=1.1',
'zope.browserpage>=3.11.0',
'zope.component',
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/bugs.txt
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/bugs.txt 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/bugs.txt 2009-12-30 17:39:18 UTC (rev 107365)
@@ -32,9 +32,9 @@
>>> form.setUpWidgets()
>>> form.widgets['title']
-<zope.app.form.browser.widget.DisplayWidget object at 0x...>
+<zope.formlibwidget.browser.widget.DisplayWidget object at 0x...>
>>> form.widgets['name']
-<zope.app.form.browser.textwidgets.TextWidget object at 0x...>
+<zope.formlibwidget.browser.textwidgets.TextWidget object at 0x...>
Make sure we have the same behaviour for non-edit forms:
@@ -47,9 +47,9 @@
>>> form = MyForm(order, request)
>>> form.setUpWidgets()
>>> form.widgets['title']
-<zope.app.form.browser.widget.DisplayWidget object at 0x...>
+<zope.formlibwidget.browser.widget.DisplayWidget object at 0x...>
>>> form.widgets['name']
-<zope.app.form.browser.textwidgets.TextWidget object at 0x...>
+<zope.formlibwidget.browser.textwidgets.TextWidget object at 0x...>
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.py 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.py 2009-12-30 17:39:18 UTC (rev 107365)
@@ -24,7 +24,7 @@
from zope.i18n import Message
from zope.i18n import translate
-from zope.app.form.browser.interfaces import IWidgetInputErrorView
+from zope.formlibwidget.browser.interfaces import IWidgetInputErrorView
from zope.publisher.interfaces.browser import IBrowserRequest
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.txt
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.txt 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/errors.txt 2009-12-30 17:39:18 UTC (rev 107365)
@@ -14,7 +14,7 @@
>>> from zope.publisher.browser import TestRequest
>>> from zope.interface.exceptions import Invalid
>>> from zope.component import getMultiAdapter
- >>> from zope.app.form.browser.interfaces import IWidgetInputErrorView
+ >>> from zope.formlibwidget.browser.interfaces import IWidgetInputErrorView
>>> error = Invalid("You are wrong!")
>>> message = getMultiAdapter((error, TestRequest()),
... IWidgetInputErrorView).snippet()
@@ -59,7 +59,7 @@
WidgetInputError exceptions also work with i18n messages:
- >>> from zope.app.form.interfaces import WidgetInputError
+ >>> from zope.formlibwidget.interfaces import WidgetInputError
>>> myError = WidgetInputError(
... field_name='summary',
... widget_title=_(u'Summary'),
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/form.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/form.py 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/form.py 2009-12-30 17:39:18 UTC (rev 107365)
@@ -38,10 +38,10 @@
from zope.lifecycleevent import Attributes
from zope.browserpage import namedtemplate
-import zope.app.form.browser.interfaces
-from zope.app.form.interfaces import IInputWidget, IDisplayWidget
-from zope.app.form.interfaces import WidgetsError, MissingInputError
-from zope.app.form.interfaces import InputErrors, WidgetInputError
+import zope.formlibwidget.browser.interfaces
+from zope.formlibwidget.interfaces import IInputWidget, IDisplayWidget
+from zope.formlibwidget.interfaces import WidgetsError, MissingInputError
+from zope.formlibwidget.interfaces import InputErrors, WidgetInputError
from zope.formlib import interfaces
from zope.i18nmessageid import MessageFactory
@@ -795,7 +795,7 @@
else:
view = component.getMultiAdapter(
(error, self.request),
- zope.app.form.browser.interfaces.IWidgetInputErrorView)
+ zope.formlibwidget.browser.interfaces.IWidgetInputErrorView)
title = getattr(error, 'widget_title', None) # duck typing
if title:
if isinstance(title, zope.i18n.Message):
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/form.txt
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/form.txt 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/form.txt 2009-12-30 17:39:18 UTC (rev 107365)
@@ -1469,9 +1469,9 @@
Let's create a simple custom widget to use in our demonstration::
- >>> import zope.app.form.browser.widget
+ >>> import zope.formlibwidget.browser.widget
- >>> class ISODisplayWidget(zope.app.form.browser.widget.DisplayWidget):
+ >>> class ISODisplayWidget(zope.formlibwidget.browser.widget.DisplayWidget):
...
... def __call__(self):
... return '<span class="iso-datetime">2005-05-04</span>'
@@ -1630,7 +1630,7 @@
Even though the form machinery only has a single errors attribute, if designers
wish to render widget errors differently than invariant errors, they can be
separated reasonably easily. The separation takes advantage of the fact that
-all widget errors should implement zope.app.form.interfaces.IWidgetInputError,
+all widget errors should implement zope.formlibwidget.interfaces.IWidgetInputError,
and invariant errors shouldn't, because they don't come from a widget.
Therefore, a simple division such as the following should suffice.
Modified: zope.formlib/branches/faassen-zaf/src/zope/formlib/tests.py
===================================================================
--- zope.formlib/branches/faassen-zaf/src/zope/formlib/tests.py 2009-12-30 17:32:58 UTC (rev 107364)
+++ zope.formlib/branches/faassen-zaf/src/zope/formlib/tests.py 2009-12-30 17:39:18 UTC (rev 107365)
@@ -32,10 +32,10 @@
import zope.testing.renormalizing
import zope.traversing.adapters
-import zope.app.form.browser
-import zope.app.form.browser.exception
-import zope.app.form.browser.interfaces
-import zope.app.form.interfaces
+import zope.formlibwidget.browser
+import zope.formlibwidget.browser.exception
+import zope.formlibwidget.browser.interfaces
+import zope.formlibwidget.interfaces
import zope.formlib
import zope.formlib.form
@@ -89,74 +89,74 @@
setUp(test)
i18nSetUp(test)
provideAdapter(
- zope.app.form.browser.TextWidget,
+ zope.formlibwidget.browser.TextWidget,
[zope.schema.interfaces.ITextLine,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IInputWidget,
+ zope.formlibwidget.interfaces.IInputWidget,
)
provideAdapter(
- zope.app.form.browser.FloatWidget,
+ zope.formlibwidget.browser.FloatWidget,
[zope.schema.interfaces.IFloat,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IInputWidget,
+ zope.formlibwidget.interfaces.IInputWidget,
)
provideAdapter(
- zope.app.form.browser.UnicodeDisplayWidget,
+ zope.formlibwidget.browser.UnicodeDisplayWidget,
[zope.schema.interfaces.IInt,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IDisplayWidget,
+ zope.formlibwidget.interfaces.IDisplayWidget,
)
provideAdapter(
- zope.app.form.browser.IntWidget,
+ zope.formlibwidget.browser.IntWidget,
[zope.schema.interfaces.IInt,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IInputWidget,
+ zope.formlibwidget.interfaces.IInputWidget,
)
provideAdapter(
- zope.app.form.browser.UnicodeDisplayWidget,
+ zope.formlibwidget.browser.UnicodeDisplayWidget,
[zope.schema.interfaces.IFloat,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IDisplayWidget,
+ zope.formlibwidget.interfaces.IDisplayWidget,
)
provideAdapter(
- zope.app.form.browser.UnicodeDisplayWidget,
+ zope.formlibwidget.browser.UnicodeDisplayWidget,
[zope.schema.interfaces.ITextLine,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IDisplayWidget,
+ zope.formlibwidget.interfaces.IDisplayWidget,
)
provideAdapter(
- zope.app.form.browser.DatetimeDisplayWidget,
+ zope.formlibwidget.browser.DatetimeDisplayWidget,
[zope.schema.interfaces.IDatetime,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IDisplayWidget,
+ zope.formlibwidget.interfaces.IDisplayWidget,
)
provideAdapter(
- zope.app.form.browser.DatetimeWidget,
+ zope.formlibwidget.browser.DatetimeWidget,
[zope.schema.interfaces.IDatetime,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.interfaces.IInputWidget,
+ zope.formlibwidget.interfaces.IInputWidget,
)
provideAdapter(
- zope.app.form.browser.exception.WidgetInputErrorView,
- [zope.app.form.interfaces.IWidgetInputError,
+ zope.formlibwidget.browser.exception.WidgetInputErrorView,
+ [zope.formlibwidget.interfaces.IWidgetInputError,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.browser.interfaces.IWidgetInputErrorView,
+ zope.formlibwidget.browser.interfaces.IWidgetInputErrorView,
)
provideAdapter(
zope.formlib.errors.InvalidErrorView,
[zope.interface.Invalid,
zope.publisher.interfaces.browser.IBrowserRequest,
],
- zope.app.form.browser.interfaces.IWidgetInputErrorView,
+ zope.formlibwidget.browser.interfaces.IWidgetInputErrorView,
)
provideAdapter(TestTemplate, name='default')
provideAdapter(requestToTZInfo)
@@ -297,16 +297,16 @@
Let's test the getWidgetsData method which is responsible for handling widget
erros raised by the widgets getInputValue method.
- >>> import zope.app.form.interfaces
+ >>> import zope.formlibwidget.interfaces
>>> class Widget(object):
- ... zope.interface.implements(zope.app.form.interfaces.IInputWidget)
+ ... zope.interface.implements(zope.formlibwidget.interfaces.IInputWidget)
... def __init__(self):
... self.name = 'form.summary'
... self.label = 'Summary'
... def hasInput(self):
... return True
... def getInputValue(self):
- ... raise zope.app.form.interfaces.WidgetInputError(
+ ... raise zope.formlibwidget.interfaces.WidgetInputError(
... field_name='summary',
... widget_title=u'Summary')
>>> widget = Widget()
@@ -314,7 +314,7 @@
>>> widgets = zope.formlib.form.Widgets(inputs, 5)
>>> errors = zope.formlib.form.getWidgetsData(widgets, 'form', {'summary':'value'})
>>> errors #doctest: +ELLIPSIS
- [<zope.app.form.interfaces.WidgetInputError instance at ...>]
+ [<zope.formlibwidget.interfaces.WidgetInputError instance at ...>]
Let's see what happens if a widget doesn't convert a ValidationError
raised by a field to a WidgetInputError. This should not happen if a widget
@@ -323,7 +323,7 @@
in the formlib as a fallback if some widget doen't handle errors correct. (ri)
>>> class Widget(object):
- ... zope.interface.implements(zope.app.form.interfaces.IInputWidget)
+ ... zope.interface.implements(zope.formlibwidget.interfaces.IInputWidget)
... def __init__(self):
... self.name = 'form.summary'
... self.label = 'summary'
@@ -336,7 +336,7 @@
>>> widgets = zope.formlib.form.Widgets(inputs, 5)
>>> errors = zope.formlib.form.getWidgetsData(widgets, 'form', {'summary':'value'})
>>> errors #doctest: +ELLIPSIS
- [<zope.app.form.interfaces.WidgetInputError instance at ...>]
+ [<zope.formlibwidget.interfaces.WidgetInputError instance at ...>]
"""
@@ -532,12 +532,12 @@
def test_suite():
- from zope.testing import doctest
+ import doctest
checker = zope.testing.renormalizing.RENormalizing([
(re.compile(r"\[WidgetInputError\('form.summary', 'summary', ValidationError\('A error message'\)\)\]"),
- r"[<zope.app.form.interfaces.WidgetInputError instance at ...>]"),
+ r"[<zope.formlibwidget.interfaces.WidgetInputError instance at ...>]"),
(re.compile(r"\[WidgetInputError\('summary', u'Summary', None\)\]"),
- r"[<zope.app.form.interfaces.WidgetInputError instance at ...>]"),
+ r"[<zope.formlibwidget.interfaces.WidgetInputError instance at ...>]"),
(re.compile(r" ValueError\('invalid literal for float\(\): (bob'|10,0'),\)"),
r"\n <exceptions.ValueError instance at ...>"),
])
More information about the Zope3-Checkins
mailing list