[Checkins] SVN: z3c.form/trunk/ - Feature: Allow "no value message"
of select widgets to be dynamilcally
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Jun 28 17:02:33 EDT 2007
Log message for revision 77192:
- Feature: Allow "no value message" of select widgets to be dynamilcally
changed using an attribute value adapter.
Changed:
U z3c.form/trunk/CHANGES.txt
U z3c.form/trunk/src/z3c/form/browser/select.py
U z3c.form/trunk/src/z3c/form/browser/select.txt
U z3c.form/trunk/src/z3c/form/widget.py
-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt 2007-06-28 20:43:10 UTC (rev 77191)
+++ z3c.form/trunk/CHANGES.txt 2007-06-28 21:02:33 UTC (rev 77192)
@@ -5,6 +5,9 @@
Version 1.4.0 (??/??/2007)
-------------------------
+- Feature: Allow "no value message" of select widgets to be dynamilcally
+ changed using an attribute value adapter.
+
- Feature: Internationalized data conversion for date, time, date/time,
integer, float and decimal. Now the locale data is used to format and parse
those data types to provide the bridge to text-based widgets. While those
@@ -17,7 +20,11 @@
of fields/widgets into a logical unit. They were designed with ease of use
in mind.
+- Feature: Button Actions -- in other words, the widget for the button field
+ -- can now be specified either as the "actionFactory" on the button field or
+ as an adapter.
+
Version 1.3.0 (6/22/2007)
-------------------------
Modified: z3c.form/trunk/src/z3c/form/browser/select.py
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/select.py 2007-06-28 20:43:10 UTC (rev 77191)
+++ z3c.form/trunk/src/z3c/form/browser/select.py 2007-06-28 21:02:33 UTC (rev 77192)
@@ -38,6 +38,10 @@
noValueMessage = _('no value')
+ # Internal attributes
+ _adapterValueAttributes = widget.SequenceWidget._adapterValueAttributes + \
+ ('noValueMessage',)
+
def isSelected(self, term):
return term.token in self.value
Modified: z3c.form/trunk/src/z3c/form/browser/select.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/select.txt 2007-06-28 20:43:10 UTC (rev 77191)
+++ z3c.form/trunk/src/z3c/form/browser/select.txt 2007-06-28 21:02:33 UTC (rev 77192)
@@ -128,3 +128,25 @@
>>> widget.update()
>>> widget.extract(default=1)
1
+
+Additionally to the standard dynamic attribute values, the select widget also
+allows dynamic values for the "no value message". Initially, we have the
+default message:
+
+ >>> widget.noValueMessage
+ u'no value'
+
+Let's now register an attribute value:
+
+ >>> from z3c.form.widget import StaticWidgetAttribute
+ >>> NoValueMessage = StaticWidgetAttribute(u'- nothing -')
+
+ >>> import zope.component
+ >>> zope.component.provideAdapter(NoValueMessage, name='noValueMessage')
+
+After updating the widget, the no value message changed to the value provided
+by the adapter:
+
+ >>> widget.update()
+ >>> widget.noValueMessage
+ u'- nothing -'
Modified: z3c.form/trunk/src/z3c/form/widget.py
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.py 2007-06-28 20:43:10 UTC (rev 77191)
+++ z3c.form/trunk/src/z3c/form/widget.py 2007-06-28 21:02:33 UTC (rev 77192)
@@ -67,6 +67,9 @@
form = None
field = None
+ # Internal attributes
+ _adapterValueAttributes = ('label', 'name')
+
def __init__(self, request):
self.request = request
@@ -117,7 +120,7 @@
converter = interfaces.IDataConverter(self)
self.value = converter.toWidgetValue(value)
# Step 2: Update selected attributes
- for attrName in ('label', 'required'):
+ for attrName in self._adapterValueAttributes:
value = zope.component.queryMultiAdapter(
(self.context, self.request, self.form, self.field, self),
interfaces.IValue, name=attrName)
More information about the Checkins
mailing list