Ignore:
Timestamp:
9 Jun 2011, 22:18:27 (13 years ago)
Author:
uli
Message:

Change WAeUPImageFile implementation: it now uses a local Blob to
store image data (much more efficient than the up to now used in-ZODB
string). We also do not check for any external filestorages any more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/image/image.py

    r6291 r6309  
    2323Components for handling image files.
    2424"""
    25 from StringIO import StringIO
     25import os
     26from ZODB.blob import Blob
    2627from hurry.file import HurryFile
    27 from hurry.file.interfaces import IFileRetrieval
    28 from zope.component import queryUtility
    2928from zope.interface import implements
    3029from waeup.sirp.image.interfaces import IWAeUPImageFile
     
    3635    """
    3736    implements(IWAeUPImageFile)
     37
     38    def __init__(self, filename, data):
     39        self.filename = filename
     40        self._file = Blob(data)
     41        self.headers = {}
     42
     43    def _getFile(self):
     44        return self._file.open('r')
     45
     46    file = property(_getFile)
     47
     48    @property
     49    def size(self):
     50        f = self._file.open('r')
     51        size = int(os.fstat(f.fileno()).st_size)
     52        f.close()
     53        return size
     54
     55    @property
     56    def data(self):
     57        f = self._file.open('r')
     58        result = f.read()
     59        f.close()
     60        return result
Note: See TracChangeset for help on using the changeset viewer.