コード例 #1
0
ファイル: file_resource.py プロジェクト: AvdN/muntjac
    def getStream(self):
        """Gets the resource as stream.

        @see: L{IApplicationResource.getStream}
        """
        try:
            ds = DownloadStream(file(self._sourceFile, "rb"), self.getMIMEType(), self.getFilename())
            length = str(getsize(self._sourceFile))
            ds.setParameter("Content-Length", length)
            ds.setCacheTime(self._cacheTime)
            return ds
        except IOError:
            # Log the exception using the application error handler
            class Error(IErrorEvent):
                def getThrowable(self):
                    return self.e

            self.getApplication().getErrorHandler().terminalError(Error())
            return None
コード例 #2
0
ファイル: file_resource.py プロジェクト: fbeneventi/muntjac
    def getStream(self):
        """Gets the resource as stream.

        @see: L{IApplicationResource.getStream}
        """
        try:
            ds = DownloadStream(file(self._sourceFile, 'rb'),
                                self.getMIMEType(), self.getFilename())
            length = str(getsize(self._sourceFile))
            ds.setParameter('Content-Length', length)
            ds.setCacheTime(self._cacheTime)
            return ds
        except IOError:
            # Log the exception using the application error handler
            class Error(IErrorEvent):
                def getThrowable(self):
                    return self.e

            self.getApplication().getErrorHandler().terminalError(Error())
            return None