[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/complexsample
- widgetapi.py:1.2
Garrett Smith
garrett at mojave-corp.com
Wed Aug 13 18:28:57 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/form/complexsample
In directory cvs.zope.org:/tmp/cvs-serv9151/src/zope/app/browser/form/complexsample
Modified Files:
widgetapi.py
Log Message:
Made the following changes to the widget machinery:
- Renamed IWidget getData to getInputValue
getInputValue no longer accepts an 'optional' flag. If value is missing or is invalid, getInputValue will raise an error. Calls made to this method should be in a try...except block to handle such conditions.
- Renamed IWidget haveData to hasInput
- Added method hasValidInput to IWidget and widget implementations
- Renamed IWidget setData to setRenderedValue
- Added functional tests for some of the core widgets - additional ftests are needed
- Deleted the class PossibleEmptyMeansMissing - it's no longer needed
- Added deprecation tests for changes to widgets
- Some widgets were refactored to use the new framework correctly
These changes were based on the proposal:
http://dev.zope.org/Zope3/ComponentArchitecture/WidgetsFormsSchemas
Not all the changes in the proposal are included in this commit. Specifically, getRawData/setRawData and the refactoring of the widget error classes are the two major changes not included in this commit.
=== Zope3/src/zope/app/browser/form/complexsample/widgetapi.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/complexsample/widgetapi.py:1.1 Mon Jul 28 14:47:30 2003
+++ Zope3/src/zope/app/browser/form/complexsample/widgetapi.py Wed Aug 13 17:27:53 2003
@@ -74,16 +74,16 @@
# Form management methods.
# Subclasses should not to override these.
- def getData(self):
+ def getInputValue(self):
if not self.__initialized:
self.__initialize()
return self.__computed_value
- def haveData(self):
+ def hasInput(self):
marker_name = self.name + "-marker"
return marker_name in self.request.form
- def setData(self, value):
+ def setRenderedValue(self, value):
assert (self.__initial_value is NullValue
or (not self.__initialized)
or self.__initial_value == value)
@@ -98,7 +98,7 @@
def __initialize(self):
self.__initialized = True
self.initialize()
- if self.haveData():
+ if self.hasInput():
self.__computed_value = self.loadValueFromRequest()
elif self.__initial_value is NullValue:
self.__computed_value = self.context.default
@@ -107,7 +107,7 @@
def applyChanges(self, content):
field = self.context
- value = self.getData()
+ value = self.getInputValue()
change = field.query(content, self) != value
if change:
field.set(content, value)
More information about the Zope3-Checkins
mailing list