ztfy/utils/file.py
changeset 0 712d20d2751e
child 2 20f3c0eb8fdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ztfy/utils/file.py	Sat Jan 10 00:35:35 2009 +0100
@@ -0,0 +1,47 @@
+### -*- coding: utf-8 -*- ####################################################
+##############################################################################
+#
+# Copyright (c) 2008 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id: $
+"""
+
+__version__   = "$Revision: $"
+__release__   = "$Id: $"
+__docformat__ = "restructuredtext"
+ 
+# import standard packages
+
+# import Zope3 interfaces
+from zope.app.file.interfaces import IFile
+from zope.schema.interfaces import IBytes
+from z3c.form.interfaces import IFileWidget
+
+# import local interfaces
+
+# import Zope3 packages
+from zope import component
+from zope.app.file import File
+from zope.schema.fieldproperty import FieldProperty
+from z3c.form.converter import FileUploadDataConverter as BaseDataConverter
+
+# import local packages
+
+
+class FileUploadDataConverter(BaseDataConverter):
+
+    component.adapts(IBytes, IFileWidget)
+
+    def toWidgetValue(self, value):
+        return value or ''