Changeset 7016 for main/waeup.sirp


Ignore:
Timestamp:
7 Nov 2011, 08:12:38 (13 years ago)
Author:
uli
Message:

More docs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/imagestorage.py

    r7010 r7016  
    233233class Basket(grok.Container):
    234234    """A basket holds a set of image files with same hash.
     235
     236    It is used for storing files as blobs in ZODB. Current sites do
     237    not use it.
     238
     239    .. deprecated:: 0.2
     240
    235241    """
    236242
     
    353359
    354360    def storeFile(self, fd, filename):
     361        """Store contents of file addressed by `fd` under filename `filename`.
     362
     363        Returns the internal file id (a string) for the file stored.
     364        """
    355365        fd.seek(0)
    356366        digest = md5digest(fd)
     
    371381
    372382class ImageStorageFileRetrieval(Persistent):
     383    """A persistent object to retrieve files stored in ZODB.
     384
     385    .. deprecated:: 0.2
     386
     387       Since we have :class:`ExtFileStore` now we do not need this
     388       class anymore.
     389    """
    373390    grok.implements(IFileRetrieval)
    374391
     
    487504        """Get a file stored under file ID `file_id`.
    488505
     506        Returns a file already opened for reading.
     507
    489508        If the file cannot be found ``None`` is returned.
     509
     510        This methods takes into account registered handlers for any
     511        marker put into the file_id.
    490512        """
    491513        marker, filename, base, ext = self.extractMarker(file_id)
     
    565587
    566588class DefaultFileStoreHandler(grok.GlobalUtility):
     589    """A default handler for external file store.
     590
     591    This handler is the fallback called by external file stores when
     592    there is no or an unknown marker in the file id.
     593    """
    567594    grok.implements(IFileStoreHandler)
    568595
    569596    def pathFromFileID(self, store, root, file_id):
     597        """Return the root path of external file store appended by file id.
     598        """
    570599        return os.path.join(root, file_id)
    571600
    572601    def createFile(self, store, root, filename, file_id, f):
     602        """Infos about what to store exactly and where.
     603
     604        When a file should be handled by an external file storage, it
     605        looks up any handlers (like this one), passes runtime infos
     606        like the storage object, root path, filename, file_id, and the
     607        raw file object itself.
     608
     609        The handler can then change the file, raise exceptions or
     610        whatever and return the result.
     611
     612        This handler returns the input file as-is, a path returned by
     613        :meth:`pathFromFileID` and an instance of
     614        :class:`hurry.file.HurryFile` for further operations.
     615
     616        Please note: although a handler has enough infos to store the
     617        file itself, it should leave that task to the calling file
     618        store.
     619        """
    573620        path = self.pathFromFileID(store, root, file_id)
    574621        return f, path, HurryFile(filename, file_id)
Note: See TracChangeset for help on using the changeset viewer.