[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Image - Image.py:1.3 configure.zcml:1.7

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


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Image
In directory cvs.zope.org:/tmp/cvs-serv24805/lib/python/Zope/App/OFS/Content/Image

Modified Files:
	Image.py configure.zcml 
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/Zope/App/OFS/Content/Image/Image.py 1.2 => 1.3 ===
 # 
 ##############################################################################
 """
-Revision Information:
 $Id$
 """
-
 import struct
 
-from Zope.App.OFS.Content.File.File import IFile, File
+from Zope.App.OFS.Content.File.File import File
+from Zope.App.OFS.Content.File.IFile import IFile
+from Zope.App.OFS.Content.File.SFile import SFile
 from Zope.App.OFS.Annotation.IAnnotatable import IAnnotatable
 from StringIO import StringIO
 
 
 class IImage(IFile):
-    """This interface defines an Image that can be displayed.
-    """
+    """This interface defines an Image that can be displayed."""
 
     def getImageSize():
         """Return a tuple (x, y) that describes the dimensions of
-           the object.
-        """
+        the object."""
+
     
+class SImage(SFile):
+    """Image properties."""
 
-class Image(File):
-    """ """
 
-    __implements__ = (
-        IImage,
-        IAnnotatable,
-        )
+class Image(File):
+    __implements__ = (SImage, IImage, IAnnotatable,)
 
     def __init__(self, data=None):
-        """ """
-        self._contentType, self._width, self._height = getImageInfo(data)
-        self.setData(data)
+        '''See interface Zope.App.OFS.Content.File.IFile.IFile'''
+        self.contentType, self._width, self._height = getImageInfo(data)
+        self.data = data
 
 
     def setData(self, data):
-        """ """
         super(Image, self).setData(data)
 
-        contentType = None
-        contentType, self._width, self._height = getImageInfo(self._data)
-        if contentType:
-            self._contentType = contentType
-
+        if data is not None:
+            contentType = None
+            contentType, self._width, self._height = getImageInfo(self.data)
+            if contentType:
+                self.contentType = contentType
 
-    
-
-    ############################################################
-    # Implementation methods for interface
-    # Zope.App.OFS.Image.IImage
 
     def getImageSize(self):
         '''See interface IImage'''
-
         return (self._width, self._height)
 
-    #
-    ############################################################
-    
+    # See schema Zope.App.OFS.File.SFile.SFile
+    data = property(File.getData, setData, None,
+                    """Contains the data of the file.""")
 
 
 def getImageInfo(data):
-    """ """
-    
     data = str(data)
     size = len(data)
     height = -1


=== Zope3/lib/python/Zope/App/OFS/Content/Image/configure.zcml 1.6 => 1.7 ===
         permission="Zope.View"
         interface=".Image.IImage" />
     <require
+        permission="Zope.View"
+        interface=".Image.SImage" />
+    <require
         permission="Zope.ManageContent"
         interface="Zope.App.OFS.Content.File.IFile.IWriteFile" />
   </content>