Updated schema fields
authorThierry Florac <thierry.florac@onf.fr>
Fri, 20 Mar 2015 17:30:42 +0100
changeset 6 f96107cb3c35
parent 5 aa402a05ef0e
child 7 89e746950918
Updated schema fields
src/pyams_file/schema.py
--- a/src/pyams_file/schema.py	Wed Mar 18 10:08:44 2015 +0100
+++ b/src/pyams_file/schema.py	Fri Mar 20 17:30:42 2015 +0100
@@ -15,8 +15,9 @@
 # import standard library
 
 # import interfaces
-from pyams_file.interfaces import IFile, IFileField, IMediaFile, IMediaField, IImage, IImageField, IThumbnailImageField, \
-    IVideo, IVideoField, IAudio, IAudioField, DELETED_FILE
+from pyams_file.interfaces import IFile, IFileField, IMediaFile, IMediaField, IImage, IImageField, \
+    IThumbnailImageField, IVideo, IVideoField, IAudio, IAudioField, DELETED_FILE
+from z3c.form.interfaces import NOT_CHANGED
 from zope.schema.interfaces import WrongType
 
 # import packages
@@ -31,13 +32,13 @@
     schema = IFile
 
     def _validate(self, value):
-        if value is DELETED_FILE:
+        if (value is DELETED_FILE) or (value is NOT_CHANGED):
             return
         elif isinstance(value, tuple):
             try:
                 filename, stream = value
                 if not isinstance(filename, str):
-                    raise WrongType(filename, str, '{0}.filename' % self.__name__)
+                    raise WrongType(filename, str, '{0}.filename'.format(self.__name__))
                 if not hasattr(stream, 'read'):
                     raise WrongType(stream, '<file-like object>', self.__name__)
             except ValueError:
@@ -61,7 +62,7 @@
 
 
 @implementer(IThumbnailImageField)
-class CthumbImageField(ImageField):
+class ThumbnailImageField(ImageField):
     """Custom field used to handle images properties with square selection"""
 
 
@@ -71,6 +72,7 @@
 
     schema = IVideo
 
+
 @implementer(IAudioField)
 class AudioField(MediaField):
     """Custom field used to store audio file"""