[Zope3-checkins] CVS: Zope3/src/zope/app/form - utility.py:1.6

R. David Murray bitz@bitdance.com
Mon, 27 Jan 2003 21:57:15 -0500


Update of /cvs-repository/Zope3/src/zope/app/form
In directory cvs.zope.org:/tmp/cvs-serv8113/zope/app/form

Modified Files:
	utility.py 
Log Message:
zope.app.form.utility had a function, fieldNames, that returned a
list of the Fields in a schema in schema order.  This is exactly
parallel to getFieldsInOrder from the schema package itself, and
it seems to me that's where it belongs.  So I added a getFieldNamesInOrder
function to schema.  I also added a getFieldNames in parallel to
getFields, to complete the set.  Everything that used fieldNames
is converted to use getFieldNamesInOrder.

The unit tests from form was actually a little stronger than those
in schema:  it made sure that all fields were returned when using
a derived schema, which the schema tests didn't.  So I added some
subschema tests to the schema test suite in addition to the tests
for the new functions themselves.



=== Zope3/src/zope/app/form/utility.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/form/utility.py:1.5	Sat Jan 25 13:30:05 2003
+++ Zope3/src/zope/app/form/utility.py	Mon Jan 27 21:56:43 2003
@@ -35,7 +35,8 @@
 __metaclass__ = type
 
 from zope.component import getView, getDefaultViewName
-from zope.schema.interfaces import IField, ValidationError
+from zope.schema import getFieldNamesInOrder
+from zope.schema.interfaces import ValidationError, IField
 from zope.app.interfaces.form import IWidget
 from zope.app.interfaces.form import WidgetsError, MissingInputError
 from zope.app.interfaces.form import InputErrors
@@ -88,17 +89,6 @@
     if value is not None and (force or not widget.haveData()):
         widget.setData(value)
 
-def fieldNames(schema):
-
-    names = []
-    for name in schema:
-        field = schema[name]
-        if IField.isImplementedBy(field):
-            names.append((field.order, name))
-
-    names.sort()
-
-    return [name[1] for name in names]
 
 def setUpWidgets(view, schema, prefix=None, force=0,
                  initial={}, names=None):