[7196] | 1 | ## $Id: image.py 7819 2012-03-08 22:28:46Z henrik $ |
---|
[5971] | 2 | ## |
---|
[7196] | 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
[5971] | 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
[7196] | 8 | ## |
---|
[5971] | 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
[7196] | 13 | ## |
---|
[5971] | 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[5976] | 18 | """ |
---|
| 19 | Components for handling image files. |
---|
| 20 | """ |
---|
[5971] | 21 | from hurry.file import HurryFile |
---|
[6536] | 22 | from hurry.file.interfaces import IFileRetrieval |
---|
| 23 | from zope.component import getUtility |
---|
[5976] | 24 | from zope.interface import implements |
---|
[7819] | 25 | from waeup.kofa.image.interfaces import IKofaImageFile |
---|
[5971] | 26 | |
---|
[7819] | 27 | class KofaImageFile(HurryFile): |
---|
[5971] | 28 | """A file prepared for storing image files. |
---|
| 29 | |
---|
[6536] | 30 | This file type is built upon :class:`hurry.file.HurryFile` but |
---|
| 31 | implements a derived marker interface to distuingish it from |
---|
| 32 | regular hurry files. |
---|
[6312] | 33 | |
---|
[7819] | 34 | To create a :class:`KofaImageFile` you should use |
---|
| 35 | :func:`createKofaImageFile`. |
---|
[5971] | 36 | """ |
---|
[7819] | 37 | implements(IKofaImageFile) |
---|
[6309] | 38 | |
---|
[6584] | 39 | def __ne__(self, other): |
---|
| 40 | # This was wrongly implemented in the base class |
---|
| 41 | try: |
---|
| 42 | return (self.filename != other.filename or |
---|
| 43 | self.data != other.data) |
---|
| 44 | except AttributeError: |
---|
| 45 | return True |
---|
| 46 | |
---|
[7819] | 47 | def createKofaImageFile(filename, f): |
---|
[6536] | 48 | retrieval = getUtility(IFileRetrieval) |
---|
| 49 | return retrieval.createFile(filename, f) |
---|