[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Image - Image.py:1.1.2.2 ImageData.py:1.1.2.2 ImageEdit.py:1.1.2.2 edit.pt:1.1.2.2
Stephan Richter
srichter@cbu.edu
Mon, 21 Jan 2002 12:42:07 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Image
In directory cvs.zope.org:/tmp/cvs-serv22486/Image
Modified Files:
Tag: Zope-3x-branch
Image.py ImageData.py ImageEdit.py edit.pt
Log Message:
NaiveFile and File:
- I fixed the Interface to also return the size of the file
- Implemented a real file that saves data chunks a la Zope 2
- Cleaned up the API, so that both NaiveFile and File can use the same
views, which I think is what Zope 3 is all about.
- TODO: Support File upload from the Web.
Image:
- Cleaned up API and methods
- renamed Interface method getSize() to getImageSize()
- Image now inherits File instead of NaiveFile
=== Zope3/lib/python/Zope/App/OFS/Image/Image.py 1.1.2.1 => 1.1.2.2 ===
import struct
-from Zope.App.OFS.File.NaiveFile import INaiveFile, NaiveFile
+from Zope.App.OFS.File.File import IFile, File
from Zope.App.Security.IAttributeRolePermissionManageable \
import IAttributeRolePermissionManageable
-class IImage(INaiveFile):
+class IImage(IFile):
"""This interface defines an Image that can be displayed.
"""
- def getSize():
+ def getImageSize():
"""Return a tuple (x, y) that describes the dimensions of
the object.
"""
-
-_RAISE_KEYERROR = []
-
-
-class Image(NaiveFile):
+class Image(File):
""" """
__implements__ = IImage
@@ -36,11 +32,11 @@
def __init__(self, data=None):
""" """
self._contentType, self._width, self._height = getImageInfo(data)
- self._data = data
+ self.setData(data)
def edit(self, data, contentType=None):
- """See interface INaiveFile
+ """See interface IFile
Note: It ignores the content type!
"""
@@ -48,14 +44,14 @@
contentType, self._width, self._height = getImageInfo(data)
if contentType:
self._contentType = contentType
- self._data = data
+ self.setData(data)
############################################################
# Implementation methods for interface
# Zope.App.OFS.Image.IImage
- def getSize(self):
+ def getImageSize(self):
'''See interface IImage'''
return (self._width, self._height)
=== Zope3/lib/python/Zope/App/OFS/Image/ImageData.py 1.1.2.1 => 1.1.2.2 ===
"""
if width is None:
- width=self.getContext().getSize()[0]
+ width=self.getContext().getImageSize()[0]
if height is None:
- height = self.getContext().getSize()[0]
+ height = self.getContext().getImageSize()[1]
# Auto-scaling support
xdelta = xscale or scale
=== Zope3/lib/python/Zope/App/OFS/Image/ImageEdit.py 1.1.2.1 => 1.1.2.2 ===
- index = PageTemplateFile('www/image_edit.pt')
-
-
-
+ index = PageTemplateFile('www/edit.pt')
=== Zope3/lib/python/Zope/App/OFS/Image/edit.pt 1.1.2.1 => 1.1.2.2 ===
<th class="EditAttributeName">Size</th>
<td class="EditAttributeValue"
- tal:content="here/getSize">
+ tal:content="here/getImageSize">
</td>
</tr>