Changeset 7053


Ignore:
Timestamp:
9 Nov 2011, 05:50:45 (13 years ago)
Author:
uli
Message:

Extend docs.
Add new convenience method to get external files by context.

File:
1 edited

Legend:

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

    r7035 r7053  
    319319        This methods takes into account registered handlers for any
    320320        marker put into the file_id.
     321
     322        .. seealso:: :class:`DefaultFileStoreHandler`
    321323        """
    322324        marker, filename, base, ext = self.extractMarker(file_id)
     
    328330        fd = open(path, 'rb')
    329331        return fd
     332
     333    def getFileByContext(self, context):
     334        """Get a file for given context.
     335
     336        Returns a file already opened for reading.
     337
     338        If the file cannot be found ``None`` is returned.
     339
     340        This method takes into account registered handlers and file
     341        name choosers for context types.
     342
     343        This is a convenience method that internally calls
     344        :meth:`getFile`.
     345
     346        .. seealso:: :class:`FileStoreNameChooser`,
     347                     :class:`DefaultFileStoreHandler`.
     348        """
     349        file_id = IFileStoreNameChooser(context).chooseName()
     350        return self.getFile(file_id)
    330351
    331352    def createFile(self, filename, f):
Note: See TracChangeset for help on using the changeset viewer.