## ## image.py ## Login : ## Started on Mon Apr 25 12:32:42 2011 Uli Fouquet ## $Id$ ## ## Copyright (C) 2011 Uli Fouquet ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """ Components for handling image files. """ import os from ZODB.blob import Blob from hurry.file import HurryFile from zope.interface import implements from waeup.sirp.image.interfaces import IWAeUPImageFile class WAeUPImageFile(HurryFile): """A file prepared for storing image files. This file type is built upon :class:`hurry.file.HurryFile`. """ implements(IWAeUPImageFile) def __init__(self, filename, data): self.filename = filename self._file = Blob(data) self.headers = {} def _getFile(self): return self._file.open('r') file = property(_getFile) @property def size(self): f = self._file.open('r') size = int(os.fstat(f.fileno()).st_size) f.close() return size @property def data(self): f = self._file.open('r') result = f.read() f.close() return result