[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Merge revision 26809
from the ZopeX3-3.0 branch.
Fred L. Drake, Jr.
fdrake at gmail.com
Wed Jul 28 12:15:25 EDT 2004
Log message for revision 26810:
Merge revision 26809 from the ZopeX3-3.0 branch.
update package metadata for new extension modules
Changed:
U Zope3/trunk/src/zope/app/form/interfaces.py
U Zope3/trunk/src/zope/app/form/tests/test_utility.py
A Zope3/trunk/src/zope/security/PACKAGE.cfg
U Zope3/trunk/src/zope/tales/pythonexpr.py
A Zope3/trunk/src/zope/thread/PACKAGE.cfg
-=-
Modified: Zope3/trunk/src/zope/app/form/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/form/interfaces.py 2004-07-28 16:07:47 UTC (rev 26809)
+++ Zope3/trunk/src/zope/app/form/interfaces.py 2004-07-28 16:15:25 UTC (rev 26810)
@@ -95,11 +95,11 @@
"""A collection of errors from widget processing.
widgetValues is a map containing the list of values that were obtained
- from the widget, keyed by field name.
+ from the widgets, keyed by field name.
"""
def __init__(self, errors, widgetsData={}):
- Exception.__init__(self, *errors)
+ ErrorContainer.__init__(self, *errors)
self.widgetsData = widgetsData
class IWidget(IView):
Modified: Zope3/trunk/src/zope/app/form/tests/test_utility.py
===================================================================
--- Zope3/trunk/src/zope/app/form/tests/test_utility.py 2004-07-28 16:07:47 UTC (rev 26809)
+++ Zope3/trunk/src/zope/app/form/tests/test_utility.py 2004-07-28 16:15:25 UTC (rev 26810)
@@ -22,14 +22,14 @@
from zope.component.exceptions import ComponentLookupError
from zope.publisher.browser import TestRequest
-from zope.schema import Field
-from zope.schema.interfaces import IField
+from zope.schema import Field, Int
+from zope.schema.interfaces import IField, IInt
from zope.app.tests import ztapi
from zope.app.publisher.browser import BrowserView
from zope.app.form import Widget
-from zope.app.form.interfaces import IWidget, IInputWidget
-from zope.app.form.interfaces import IDisplayWidget, WidgetsError
+from zope.app.form.interfaces import IWidget, IInputWidget, IDisplayWidget
+from zope.app.form.interfaces import ConversionError, InputErrors, WidgetsError
from zope.app.form.utility import no_value, setUpWidget, setUpWidgets
from zope.app.form.utility import setUpEditWidgets, setUpDisplayWidgets
@@ -51,6 +51,12 @@
class Bar(Field):
implements(IBar)
+
+class IBaz(IInt):
+ pass
+
+class Baz(Int):
+ implements(IBaz)
class IContent(Interface):
foo = Foo()
@@ -59,10 +65,10 @@
class Content(object):
implements(IContent)
foo = 'Foo'
-
+
class IFooWidget(IWidget):
pass
-
+
class IBarWidget(IWidget):
pass
@@ -76,7 +82,11 @@
implements(IBarWidget)
def getRenderedValue(self): return self._data # exposes _data for testing
def renderedValueSet(self): return self._renderedValueSet() # for testing
-
+
+class BazWidget(Widget):
+ def getRenderedValue(self): return self._data # exposes _data for testing
+ def renderedValueSet(self): return self._renderedValueSet() # for testing
+
def setUp():
"""Setup for tests."""
placelesssetup.setUp()
@@ -712,13 +722,17 @@
>>> class InputWidget(Widget):
... implements(IInputWidget)
... input = None
+ ... valid = True
... def hasInput(self):
... return input is not None
... def applyChanges(self, object):
+ ... if not self.valid:
+ ... raise ConversionError('invalid input')
... field = self.context
... field.set(object, self.input)
... return True
>>> ztapi.browserViewProviding(IFoo, InputWidget, IInputWidget)
+ >>> ztapi.browserViewProviding(IBar, InputWidget, IInputWidget)
Before calling applyWidgetsUpdate, we need to configure a context and
a view with edit widgets:
@@ -761,6 +775,28 @@
Traceback (most recent call last):
AttributeError: 'BrowserView' object has no attribute 'foo_widget'
+ When applyWidgetsChanges is called with multiple form
+ fields, some with valid data and some with invalid data, none
+ of the data is applied:
+
+ >>> context = Content()
+ >>> view = BrowserView(context, request)
+ >>> setUpEditWidgets(view, IContent, names=('foo', 'bar'))
+ >>> view.foo_widget.input = 'a'
+ >>> view.bar_widget.input = 'b'
+ >>> view.bar_widget.valid = False
+ >>> context.foo
+ 'Foo'
+ >>> getattr(context, 'bar', 'not really')
+ 'not really'
+ >>> applyWidgetsChanges(view, IContent, names=('foo', 'bar'))
+ Traceback (most recent call last):
+ WidgetsError: ConversionError: ('invalid input', None)
+ >>> context.foo
+ 'a'
+ >>> getattr(context, 'bar', 'not really')
+ 'not really'
+
>>> tearDown()
"""
Copied: Zope3/trunk/src/zope/security/PACKAGE.cfg (from rev 26809, Zope3/branches/ZopeX3-3.0/src/zope/security/PACKAGE.cfg)
Modified: Zope3/trunk/src/zope/tales/pythonexpr.py
===================================================================
--- Zope3/trunk/src/zope/tales/pythonexpr.py 2004-07-28 16:07:47 UTC (rev 26809)
+++ Zope3/trunk/src/zope/tales/pythonexpr.py 2004-07-28 16:15:25 UTC (rev 26810)
@@ -31,7 +31,8 @@
return compile(text, filename, 'eval')
def _bind_used_names(self, econtext, builtins):
- # Bind template variables
+ # Construct a dictionary of globals with which the Python
+ # expression should be evaluated.
names = {}
vars = econtext.vars
marker = self
Copied: Zope3/trunk/src/zope/thread/PACKAGE.cfg (from rev 26809, Zope3/branches/ZopeX3-3.0/src/zope/thread/PACKAGE.cfg)
More information about the Zope3-Checkins
mailing list