[Zope3-checkins] CVS: Zope3/lib/python/Zope/Schema - _Schema.py:1.4 __init__.py:1.7

Martijn Faassen m.faassen@vet.uu.nl
Thu, 12 Dec 2002 05:42:33 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Schema
In directory cvs.zope.org:/tmp/cvs-serv15480

Modified Files:
	_Schema.py __init__.py 
Log Message:
Added getFieldsInOrder, a way to get a list of (name, field) tuples
for a schema in its schema-defined order. 


=== Zope3/lib/python/Zope/Schema/_Schema.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Schema/_Schema.py:1.3	Wed Sep 11 18:06:41 2002
+++ Zope3/lib/python/Zope/Schema/_Schema.py	Thu Dec 12 05:42:33 2002
@@ -28,6 +28,13 @@
             fields[name] = attr
     return fields
 
+def getFieldsInOrder(schema,
+                     _fieldsorter=lambda x, y: cmp(x[1].order, y[1].order)):
+    """Get a list of (name, value) tuples in native schema order.
+    """
+    fields = getFields(schema).items()
+    fields.sort(_fieldsorter)
+    return fields
 
 # validate functions either return silently, or raise a ValidationError
 # or in case of the validate*All functions, a ValidationErrosAll exception.


=== Zope3/lib/python/Zope/Schema/__init__.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/Schema/__init__.py:1.6	Mon Dec  9 11:28:58 2002
+++ Zope3/lib/python/Zope/Schema/__init__.py	Thu Dec 12 05:42:33 2002
@@ -20,4 +20,5 @@
 from _Field import Sequence
 from _Field import Bytes, BytesLine, Text, TextLine, Bool, Int, Float
 from _Field import Tuple, List, Dict, Datetime
-from _Schema import validateMapping, validateMappingAll, getFields
+from _Schema import validateMapping, validateMappingAll,\
+     getFields, getFieldsInOrder