There are no implemented interfaces.
There are no attributes in this class.
show()
Sets various headers if the request is present and returns the data of the file. If the "If-Modified-Since" header is set and the context implements IZopeDublinCore, data is only returned if the modification date of the context is new than the date in the "If-Modified-Since" header >>> from zope.publisher.browser import BrowserView, TestRequest >>> class FileTestView(FileView, BrowserView): pass >>> import pytz >>> class MyFile(object): ... contentType='text/plain' ... data="data of file" ... modified = datetime(2006,1,1,tzinfo=pytz.utc) ... def getSize(self): ... return len(self.data)
>>> aFile = MyFile() >>> request = TestRequest() >>> view = FileTestView(aFile,request) >>> view.show() 'data of file' >>> request.response.getHeader('Content-Type') 'text/plain' >>> request.response.getHeader('Content-Length') '12'
If the file is adaptable to IZopeDublinCore the "Last-Modified" header is also set.
>>> request.response.getHeader('Last-Modified') is None True
For the test we just declare that our file provides IZopeDublinCore >>> from zope.interface import directlyProvides >>> directlyProvides(aFile,IZopeDublinCore) >>> request = TestRequest() >>> view = FileTestView(aFile,request) >>> view.show() 'data of file' >>> request.response.getHeader('Last-Modified') 'Sun, 01 Jan 2006 00:00:00 GMT'
If the "If-Modified-Since" header is set and is newer a 304 status is returned and the value is empty.
>>> modified = datetime(2007,12,31,tzinfo=pytz.utc) >>> modHeader = zope.datetime.rfc1123_date(zope.datetime.time(modified.isoformat())) >>> request = TestRequest(IF_MODIFIED_SINCE=modHeader)
>>> view = FileTestView(aFile,request) >>> view.show() '' >>> request.response.getStatus() 304