ztfy/utils/file.py
changeset 0 712d20d2751e
child 2 20f3c0eb8fdf
equal deleted inserted replaced
-1:000000000000 0:712d20d2751e
       
     1 ### -*- coding: utf-8 -*- ####################################################
       
     2 ##############################################################################
       
     3 #
       
     4 # Copyright (c) 2008 Thierry Florac <tflorac AT ulthar.net>
       
     5 # All Rights Reserved.
       
     6 #
       
     7 # This software is subject to the provisions of the Zope Public License,
       
     8 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     9 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
    10 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    11 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    12 # FOR A PARTICULAR PURPOSE.
       
    13 #
       
    14 ##############################################################################
       
    15 """
       
    16 
       
    17 $Id: $
       
    18 """
       
    19 
       
    20 __version__   = "$Revision: $"
       
    21 __release__   = "$Id: $"
       
    22 __docformat__ = "restructuredtext"
       
    23  
       
    24 # import standard packages
       
    25 
       
    26 # import Zope3 interfaces
       
    27 from zope.app.file.interfaces import IFile
       
    28 from zope.schema.interfaces import IBytes
       
    29 from z3c.form.interfaces import IFileWidget
       
    30 
       
    31 # import local interfaces
       
    32 
       
    33 # import Zope3 packages
       
    34 from zope import component
       
    35 from zope.app.file import File
       
    36 from zope.schema.fieldproperty import FieldProperty
       
    37 from z3c.form.converter import FileUploadDataConverter as BaseDataConverter
       
    38 
       
    39 # import local packages
       
    40 
       
    41 
       
    42 class FileUploadDataConverter(BaseDataConverter):
       
    43 
       
    44     component.adapts(IBytes, IFileWidget)
       
    45 
       
    46     def toWidgetValue(self, value):
       
    47         return value or ''