[Checkins] SVN: z3c.form/trunk/ Use nocall: modifier in orderedselect_input.pt to avoid calling list entry if it is callable.
Dan Korostelev
nadako at gmail.com
Tue Sep 2 14:43:37 EDT 2008
Log message for revision 90723:
Use nocall: modifier in orderedselect_input.pt to avoid calling list entry if it is callable.
Changed:
U z3c.form/trunk/CHANGES.txt
U z3c.form/trunk/src/z3c/form/browser/orderedselect.txt
U z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt
-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt 2008-09-02 18:36:28 UTC (rev 90722)
+++ z3c.form/trunk/CHANGES.txt 2008-09-02 18:43:37 UTC (rev 90723)
@@ -5,6 +5,9 @@
Version 2.0.0 (2008-??-??)
--------------------------
+- Bug: Use nocall: modifier in orderedselect_input.pt to avoid calling
+ list entry if it is callable.
+
- Feature: The `TypeError` message used when a field does not provide
``IFormUnicode`` now also contains the type of the field.
Modified: z3c.form/trunk/src/z3c/form/browser/orderedselect.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/orderedselect.txt 2008-09-02 18:36:28 UTC (rev 90722)
+++ z3c.form/trunk/src/z3c/form/browser/orderedselect.txt 2008-09-02 18:43:37 UTC (rev 90723)
@@ -186,3 +186,44 @@
>>> widget.update()
>>> widget.extract()
<NOVALUE>
+
+Finally, let's check correctness of widget rendering in one rare case when
+we got selection terms with callable values and without titles. For example,
+you can get those terms when you using the "Content Types" vocabulary from
+zope.app.content.
+
+ >>> class CallableValue(object):
+ ... def __init__(self, value):
+ ... self.value = value
+ ... def __call__(self):
+ ... pass
+ ... def __str__(self):
+ ... return 'Callable Value %s' % self.value
+
+ >>> class SelectionTermsWithCallableValues(z3c.form.term.Terms):
+ ... def __init__(self, context, request, form, field, widget):
+ ... self.terms = SimpleVocabulary([
+ ... SimpleVocabulary.createTerm(CallableValue(1), 'a'),
+ ... SimpleVocabulary.createTerm(CallableValue(2), 'b'),
+ ... SimpleVocabulary.createTerm(CallableValue(3), 'c')
+ ... ])
+
+ >>> widget.terms = SelectionTermsWithCallableValues(None, TestRequest(), None, None, widget)
+ >>> widget.update()
+ >>> print widget.render()
+ <script type="text/javascript">
+ ...
+ </script>
+ <table border="0" class="ordered-selection-field">
+ <tr>
+ <td>
+ <select id="widget-id-from" name="widget.name.from"
+ size="5" multiple="multiple">
+ <option value="a">Callable Value 1</option>
+ <option value="b">Callable Value 2</option>
+ <option value="c">Callable Value 3</option>
+ </select>
+ </td>
+ ...
+ </tr>
+ </table>
Modified: z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt 2008-09-02 18:36:28 UTC (rev 90722)
+++ z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt 2008-09-02 18:43:37 UTC (rev 90723)
@@ -165,7 +165,7 @@
size view/size">
<option tal:repeat="entry view/notselectedItems"
tal:attributes="value entry/value"
- tal:content="entry/content" i18n:translate=""/>
+ tal:content="nocall:entry/content" i18n:translate=""/>
</select>
</td>
<td>
@@ -206,7 +206,7 @@
size view/size">
<option tal:repeat="entry view/selectedItems"
tal:attributes="value entry/value"
- tal:content="entry/content" i18n:translate=""/>
+ tal:content="nocall:entry/content" i18n:translate=""/>
</select>
<input name="foo-empty-marker" type="hidden"
tal:attributes="name string:${view/name}-empty-marker"/>
More information about the Checkins
mailing list