[Zope3-checkins] CVS: Zope3/lib/python/Schema - Converter.py:1.4 _Field.py:1.10

Stephan Richter srichter@cbu.edu
Fri, 19 Jul 2002 09:13:00 -0400


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

Modified Files:
	Converter.py _Field.py 
Log Message:
Okay, I finished the Forms work. Schema and Forms completely replace the
old Formulator code now. I have switched all the Content objects to using
Schema + Forms; especially the SQL Script has an interesting demo on how
to write your custom fields.

However, I am not satisfied with all my design decisions. There is still
a lot of work to be done in Converters and Widgets. Please contact Martijn
and/or me if you would like to help.


=== Zope3/lib/python/Schema/Converter.py 1.3 => 1.4 ===
 
 StrToFloatConverter = _functionConverterFactory('StrToFloatConverter', float)
 FloatToStrConverter = _functionConverterFactory('FloatToStrConverter', str)
+
+
+class FileToStrConverter(object):
+    __implements__ = IConverter    
+
+    def convert(self, value):
+        try:
+            value = value.read()
+        except Exception, e:
+            raise ConversionError('Value is not a file object', e)
+        else:
+            if len(value):
+                return value
+            else:
+                return None


=== Zope3/lib/python/Schema/_Field.py 1.9 => 1.10 ===
     __implements__ = ()
     type = None
     default = None
+    setter = None
+    getter = None
     required = 0
     allowed_values = []